(function(window){
	var dk_result ={};//读卡结果全局变量
	_commonutil ={
/*****************************************************************************************************************************************************/
/*****************************************************************************************************************************************************/
/*****************************************************************************************************************************************************/
/*****************************************************************************************************************************************************/
/*****************************************************************************************************************************************************/
/*****************************************************************************************************************************************************/
/*****************************************************************************************************************************************************/
/******系统级公共方法开始***系统级公共方法开始***系统级公共方法开始**系统级公共方法开始**系统级公共方法开始***系统级公共方法开始***系统级公共方法开始********/
		/**
		 * 弹出js异常信息
		 * @param {Object} exception
		 */
		openErrorTracePanel : function (exception){
			var text = exception.stack||exception.message;//IE9及以下stack为undefined，显示message
			if(!layer){
				alert(text);
				return;
			}
			layer.open({
				  type: 1
				  ,title: '系统异常-请复制异常信息告知系统供应商' //不显示标题栏
				  ,closeBtn: false
				  ,area: ['600px','400px']
				  ,shade: 0.1
				  ,id: 'layer_exception_notice' //设定一个id，防止重复弹出
				  ,resize: false
				  ,btn: ['确定']
				  ,btnAlign: 'c'
				  ,moveType: 1 //拖拽模式，0或者1
				  ,content: '<div id="layer_errmsg_div" style="padding: 20px 50px 20px 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">' + text + '</div>'
			});
		},
		/**
		 * 获取静态资源路径
		 */
		getPublicUrl: function() {
			var path = window.document.location.href;  
			var index_length = path.indexOf('jwythglxt');
			path = path.substr(0, index_length + 9);
			url = path + "/public";
			return url;
		},
		/**
		 * 获取服务地址
		 */
		getServiceUrl : function(){
			try{
				var path = window.document.location.href;  
				var index_length = path.indexOf('jwythglxt');
				path = path.substr(0, index_length + 9);
				url = path + "/public/data/serviceUrl.json";
				var baseurl = "";
				$.ajax({
		            type: "GET",
		            async: false,
		            dataType: "json",
		            url: url,
		            cache: false,
		            success: function (data) {
		              	var inurl = commonUtil.uncompileStr(data.inurl);
						var outurl = commonUtil.uncompileStr(data.outurl);
						var curWwwPath = window.document.location.href;  
						var pathName = window.document.location.pathname;  
					    var pos = curWwwPath.indexOf(pathName);
					    var localhostPaht = curWwwPath.substring(0, pos);
					    if(inurl.indexOf(localhostPaht) >= 0){
					    	baseurl = inurl;
					    }else if(outurl.indexOf(localhostPaht) >= 0){
					    	baseurl = outurl;
					    }else if(localhostPaht.indexOf("127.0.0.1") >= 0){
					    	baseurl = inurl;
					    }else{
					    	baseurl = localhostPaht + "/jwythapi";
					    }
		            },
		            error: function (err) {
		                alert('获取数据服务器地址出错');
		                return;
		            }
		        });
		        return baseurl;
			}catch(e){
		    	commonUtil.openErrorTracePanel(e);
		    }
		},
		/**
		 * 获取顶级菜单id
		 */
		getTopcdid : function(){
			try{
				var cd = {};
				var path = window.document.location.href;  
				var index_length = path.indexOf('jwythglxt');
				path = path.substr(0, index_length + 9);
				url = path + "/public/data/serviceUrl.json";
				$.ajax({
		            type: "GET",
		            async: false,
		            dataType: "json",
		            url: url,
		            cache: false,
		            success: function (data) {
		              	cd.topcdid = commonUtil.uncompileStr(data.topcdid);
		              	cd.cdid_superadmin = commonUtil.uncompileStr(data.cdid_superadmin);
		              	cd.cdid_resource = commonUtil.uncompileStr(data.cdid_resource);
		            },
		            error: function (err) {
		                alert('获取数据服务器地址出错');
		                return;
		            }
		        });
		        if(!cd.topcdid){
		        	alert('顶级菜单未配置');
		        	cd.topcdid = " 0 0 ";
		        	cd.cdid_superadmin = "";
		        	cd.cdid_resource = "";
		        }
		        return cd;
			}catch(e){
		    	commonUtil.openErrorTracePanel(e);
		    }
		},
		/**
		 * 获取人员机构菜单
		 */
		getRyjgMenu : function(){
			try{
				var ryygMenu = {};
				var path = window.document.location.href;  
				var index_length = path.indexOf('jwythglxt');
				path = path.substr(0, index_length + 9);
				url = path + "/public/data/ryjg_menu.json";
				$.ajax({
		            type: "GET",
		            async: false,
		            dataType: "json",
		            url: url,
		            cache: false,
		            success: function (data) {
		              	ryygMenu = data;
		            },
		            error: function (err) {
		                alert('获取数据服务器地址出错');
		                return;
		            }
		        });
		        return ryygMenu;
			}catch(e){
		    	commonUtil.openErrorTracePanel(e);
		    }
		},
		/**
		 * 异步请求数据通用方法
		 * @param {Object} url 
		 * @param {Object} data
		 * @param {Object} callback
		 */
		commonQueryAsyncHttppost_callback:function(url, data, callback){
			try{
				//url处理
				url = commonUtil.replaceUrl(url,"query");
				
                var baseurl = commonUtil.getServiceUrl();
				
				//参数转base64
//				if(data){
//              	pardataam = encodeURI(BASE64.encoder(data));
//              }
//				var param={"data": data};
				var param={"data": JSON.stringify(data)};
				console.info(url + JSON.stringify(data));
				//打开遮罩
				var loadings = commonUtil.layerLoading();
				$.ajax({
				    url: baseurl+url,
				    type: "POST",
				    xhrFields: {
           				withCredentials: true
       				 },
       				 crossDomain: true,
				    data: param,
				    async: true,
				    success: function(result){
				    	commonUtil.layerCloseLoading(loadings);
				     	var rdata = JSON.parse(result);
				    	if("1" == rdata.code){
				    		callback(rdata.data);
				    	}else{
				    		if(rdata.msg == '请先登录'){
				    			var path = window.document.location.href;  
								var index_length = path.indexOf('jwythglxt');
								path = path.substr(0, index_length + 9);
								var loginurl = path + "/web/login/login.html";
				    			layer.alert('登录超时,请重新登录',function(){
				    				top.window.location.href= loginurl;
				    			})
				    			return;
				    		}
				    		if(rdata.msg == '该用户已在其他电脑上登陆！'){
				    			var path = window.document.location.href;  
								var index_length = path.indexOf('jwythglxt');
								path = path.substr(0, index_length + 9);
								var loginurl = path + "/web/login/login.html";
				    			layer.alert('该用户已在其他电脑上登陆！',function(){
				    				top.window.location.href= loginurl;
				    			})
				    			return;
				    		}
				    		alert(rdata.msg);
				    		console.info(rdata.msg + "  url:" + url)
				    		return;
				    	}
				    },
                    error:function(e,m,n){
                        layer.alert(n);
                        commonUtil.layerCloseLoading(loadings);
                    }
				});
				
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * ajax同步请求数据
		 * @param {Object} url
		 * @param {Object} data
		 */
		commonQueryHttppost:function(url, data){
			try{
				//url处理
				url = commonUtil.replaceUrl(url,"query");
				
				var baseurl = commonUtil.getServiceUrl();
				
				//参数转base64
//				if(data){
//              	pardataam = encodeURI(BASE64.encoder(data));
//              }
//				var param={"data": data};
				var param={"data": JSON.stringify(data)};
				var resultData = "";
				console.info(url + JSON.stringify(data));
				//打开遮罩
				var loadings = commonUtil.layerLoading();
				$.ajax({
				     url: baseurl+url,
				     type: "POST",
				     xhrFields: {
           				withCredentials: true
       				 },
       				 crossDomain: true,
				     data: param,
				     async: false,
				     success: function(result){
				    	var rdata = JSON.parse(result);
				    	if("1" == rdata.code){
				    		resultData = rdata.data;
				    	}else{
				    		if(rdata.msg == '请先登录'){
				    			var path = window.document.location.href;  
								var index_length = path.indexOf('jwythglxt');
								path = path.substr(0, index_length + 9);
								var loginurl = path + "/web/login/login.html";
				    			layer.alert('登录超时,请重新登录',function(){
				    				top.window.location.href= loginurl;
				    			})
				    			return;
				    		}
				    		if(rdata.msg == '该用户已在其他电脑上登陆！'){
				    			var path = window.document.location.href;  
								var index_length = path.indexOf('jwythglxt');
								path = path.substr(0, index_length + 9);
								var loginurl = path + "/web/login/login.html";
				    			layer.alert('该用户已在其他电脑上登陆！',function(){
				    				top.window.location.href= loginurl;
				    			})
				    			return;
				    		}
				    		alert(rdata.msg);
				    		console.info(rdata.msg + "  url:" + url)
				    		return;
				    	}
				     }
				});
				commonUtil.layerCloseLoading(loadings);
				return resultData;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 通用提交数据
		 * @param {Object} url
		 * @param {Object} data
		 */
		commonSubmitHttppost:function(url, data){
			try{
				//url处理
				url = commonUtil.replaceUrl(url,"commit");
				
                var baseurl = commonUtil.getServiceUrl();
                //参数转base64
//				if(data){
//              	pardataam = encodeURI(BASE64.encoder(data));
//              }
//				var param={"data": data};
				var param={"data": JSON.stringify(data)};   
				var resultData = "";
				console.info("commit:   " + url + JSON.stringify(data));
				$.ajax({
				    url: baseurl + url,
				    type: "POST",
				    xhrFields: {
           				withCredentials: true
       				 },
       				 crossDomain: true,
				    data: param,
				    async: false,
				    success: function(result){
				    	resultData=result;
				    }
				});
				if(resultData){
					resultData = JSON.parse(resultData);
				}
				return resultData;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * ajax异步请求数据_无遮罩
		 * @param {Object} url
		 * @param {Object} data
		 * @param {Object} callback
		 */
		commonQueryAsyncHttppost_callback_noloadings:function(url, data, callback){
			try{
				//url处理
				url = commonUtil.replaceUrl(url,"query");
				
                var baseurl = commonUtil.getServiceUrl();
				
				//参数转base64
//				if(data){
//              	pardataam = encodeURI(BASE64.encoder(data));
//              }
//				var param={"data": data};
				var param={"data": JSON.stringify(data)};
				$.ajax({
				    url: baseurl+url,
				    type: "POST",
				    xhrFields: {
           				withCredentials: true
       				 },
       				 crossDomain: true,
				    data: param,
				    async: true,
				    success: function(result){
				     	var rdata = JSON.parse(result);
				    	if("1" == rdata.code){
				    		callback(rdata.data);
				    	}else{
				    		if(rdata.msg == '请先登录'){
				    			var path = window.document.location.href;  
								var index_length = path.indexOf('jwythglxt');
								path = path.substr(0, index_length + 9);
								var loginurl = path + "/web/login/login.html";
				    			layer.alert('登录超时,请重新登录',function(){
				    				top.window.location.href= loginurl;
				    			})
				    			return;
				    		}
				    		if(rdata.msg == '该用户已在其他电脑上登陆！'){
				    			var path = window.document.location.href;  
								var index_length = path.indexOf('jwythglxt');
								path = path.substr(0, index_length + 9);
								var loginurl = path + "/web/login/login.html";
				    			layer.alert('该用户已在其他电脑上登陆！',function(){
				    				top.window.location.href= loginurl;
				    			})
				    			return;
				    		}
				    		alert(rdata.msg);
				    		console.info(rdata.msg + "  url:" + url)
				    		return;
				    	}
				    },
                    error:function(e,m,n){
                        layer.alert(n);
                    }
				});
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 通用提交数据,自定义url
		 * @param {Object} url
		 * @param {Object} data
		 */
		commonSubmitHttppost_selfurl:function(url, data){
			try{
				//url处理
				url = commonUtil.replaceUrl(url,"commit");
				
                //参数转base64
//				if(data){
//              	pardataam = encodeURI(BASE64.encoder(data));
//              }
//				var param={"data": data};
				var param={"data": JSON.stringify(data)};   
				var resultData = "";
				console.info("commit:   " + url + JSON.stringify(data));
				$.ajax({
				    url: url,
				    type: "POST",
				    xhrFields: {
           				withCredentials: true
       				 },
       				 crossDomain: true,
				    data: param,
				    async: false,
				    success: function(result){
				    	resultData=result;
				    }
				});
				if(resultData){
					resultData = JSON.parse(resultData);
				}
				return resultData;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 取请求路径中的参数
		 * 
		 * @param {String} key 
		 */
		getUrlParam : function(key) {
		  var params=this.getUrlParams();
		  if(params && params[key]){
			  return params[key];
		  }else{
			  return "";
		  }
		},
		/**
		 * 获取url参数
		 */
		getUrlParams : function(){
			try{
				var url = location.search; //获取url中"?"符后的字串
				var params = {};
			    if(url.indexOf("?") != -1) {
			        var str = url.substr(1);
			        var datas = str.split("&");
					for(var i = 0 ; i < datas.length ; i++){
						var tempData = datas[i].split("=");
						params[tempData[0]]= decodeURI(tempData[1]);
					}
			    }
		    	return params;
		  	}catch(e){
		  	commonutil.openErrorTracePanel(e);
		  	}
		},
		/**
		 * 获取用户信息
		 */
		getUser : function(){
			var user_info_data = "";
			if(!user_info_data){
				var user_info = sessionStorage.getItem("userinfo");
				user_info_data = JSON.parse(user_info);
				user_info_ryxx = user_info_data.ryxx;
				user_info_ryxx.yhqx = user_info_data.yhqx;
				user_info_ryxx.jgjs = user_info_data.jgjs;
				if(!user_info_ryxx){
					window.location.href = "../login/login.html";
				}else{
//					user_info_data.jgjb = user_info_data.xzjb;
				}
				return user_info_ryxx;
			}else{
				return user_info_ryxx;
			}
			//czyjgjb 1:省 2：市 3：区县 4：医院
//			return {"jgdm":"330102026", "userid":"superadmin", "username":"浙江省疾控", "jgjb":"1", "xzqh":"330000", "jgid":"1101", "superadmin":"1"};
//			return {"jgdm":"331002006", "userid":"admin_jjjk", "username":"椒江区疾病预防控制中心", "jgjb":"3", "xzqh":"331002"};
//			return {"jgdm":"331002020", "userid":"admin_tzs", "username":"台州市疾病预防控制中心", "jgjb":"2", "xzqh":"331000"};
//			return {"jgdm":"331002011", "userid":"admin_qsjd", "username":"椒江区前所街道卫生院", "jgjb":"4", "xzqh":"33100204"};
//			return {"jgdm":"331003010", "userid":"admin_hyjk", "username":"黄岩区疾病预防控制中心", "jgjb":"3", "xzqh":"331003"};
		},
/*****************************************************************************************************************************************************/
/*****************************************************************************************************************************************************/
/*****************************************************************************************************************************************************/
/*****************************************************************************************************************************************************/
/*****************************************************************************************************************************************************/
/*****************************************************************************************************************************************************/
/*****************************************************************************************************************************************************/
/******系统级公共方法结束***系统级公共方法结束***系统级公共方法结束**系统级公共方法结束**系统级公共方法结束***系统级公共方法结束***系统级公共方法结束********/
		/**
		 * 单选框赋值，不执行form.render()
		 * @param {Object} name
		 * @param {Object} value
		 */
		setRadioValue : function(name, value){
			try{
				$("input[type=radio][name='"+ name +"'][value='" + value + "']").prop("checked", true);
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 复选框赋值，不执行form.render()
		 * @param {Object} name
		 * @param {Object} values
		 * @param {Object} type 为空，只勾选 ; cancel 取消勾选; reset 重新勾选所有选项;
		 */
		setCheckboxValue : function(name, values, type){
			try{
				//修改方法，原方法只能给复选框赋值，不能取消勾选
				if(name){
					values=values+",";
					$("input[type=checkbox][name='"+ name +"']").each(function(index,obj){
						var valueI = $(obj).attr("value")+",";
						if(type=="reset"){
							if(values.indexOf(valueI)>=0){
								$(obj).prop("checked", true);
							} else {
								$(obj).prop("checked", false);
							}
						} else if(type=="cancel") {
							if(values.indexOf(valueI)>=0){
								$(obj).prop("checked", false);
							} 
						} else {
							if(values.indexOf(valueI)>=0){
								$(obj).prop("checked", true);
							} 
						}
					});
				}
				/*if(values){
					value_arr = values.split(",");
					for(var i = 0; i < values.length; i++){
						$("input[type=checkbox][name='"+ name +"'][value='" + value_arr[i] + "']").prop("checked", true);
					}
				}*/
				
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 将用户信息封装到提交参数中
		 * @param {Object} param
		 * @param {Object} user
		 */
		setUserParam : function(param, user){
			try{
				if(!param){
					param = {};
				}
				if(!user){
					user = commonUtil.getUser();
				}
				//机构代码
				param.czyjgdm = user.jgdm;
				//机构级别
				param.czyjgjb = user.jgjb;
				//用户id
				param.czyyhid = user.ryid;
				//用户姓名
				param.czyyhxm = user.username;
				//机构id
				param.czyjgid = user.jgid;
				//机构名称
				param.czyjgmc = user.jgmc;
				return param;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 将用户信息封装到查询参数中
		 * @param {Object} param
		 * @param {Object} user
		 */
		setQueryparam: function(param, user){
			try{
				if(!param){
					param = {};
				}
				if(!user){
					user = commonUtil.getUser();
				}
				//机构代码
				param.czyjgdm = user.jgdm;
				//机构级别
				param.czyjgjb = user.jgjb;
				//用户id
				param.czyyhid = user.ryid;
				//用户姓名
				param.czyyhxm = user.username;
				//机构id
				param.czyjgid = user.jgid;
				//操作员管理机构id
				param.czygljgid = user.jgid;
				//操作员人员身份
				param.czyrysf = user.rysf;
				//操作员网格代码
				param.czywgdm = user.wgdm;
				//操作员团长团队ids
				param.czytztdids = user.tztdids;
				//查询档案是否启用操作员所在机构的限制权限,默认启用（如：疾控中心在卫计局子节点，但是需要查询所有数据，则停用该限制，并且设置机构网格）
				param.czyszjgcxtj = "1";
				return param;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 获取管理机构id
		 * @param {Object} user
		 */
		getGljgid: function(user){
			try{
				if(!user){
					user = commonUtil.getUser();
				}
				return user.jgid;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		/**
		 * 创建combox table
		 * @param {Object} domid
		 * @param {Object} placeholder
		 * @param {Object} textFieldValue
		 * @param {Object} columnsData
		 * @param {Object} func
		 * @param {Object} url
		 */
		creatDatagrid:function(domid,placeholder,textFieldValue,columnsData,func,url){
			var mycombogrid = new Combogrid();
			mycombogrid.init({
			    // 对应要转换为控件的dom对象
			    dom: $('#'+domid)[0],
			    verify:'',
			    placeholder:placeholder,
			    className:'datagrid-input',
			    datagrid: {
			        // 弹出表格的宽度单位PX
			        width: 500,
			        // 写入input对应的列名
			        textField: textFieldValue,
			        // 列设置其中align有（left、center、right）
			        columns: columnsData,
			        pagelist:["firstPage","prePage","pageInfo","nextPage","lastPage"],
			        // 加载成功回调函数
			        loadSuccess: function(keyword, pageNum, pageSize) {
			        	pageSize=10;
			        	if(keyword){
							var tPageSize = 10;//pageSize;
							var param = {
									rn_s: (pageNum - 1) * (tPageSize) + 1 + '',
									rn_e: pageNum * (tPageSize) + '',
									keyword: keyword
							};
							var	returndata = commonUtil.commonQueryHttppost(url, param);
								if(returndata){
									if(returndata.length == 0) {
									layer.msg('未检索到数据', {
										time: 1500
									});
									return;
								}
								//传入页码信息
								var pageInfo = {
										pageNum: pageNum,
										pageSize: pageSize,
										totalPage: Math.ceil(returndata[0].total / tPageSize)
									}
									// 绑定数据
									// 加载完成写入数据
								mycombogrid.setData(returndata, pageInfo);
							}
							
						}
			        },
			        // 行选中回调函数
			        selectRow: function(rowData) {
			        	eval(func+"('"+JSON.stringify(rowData)+"','"+domid+"')");
			        }
			    }
			
			});
			return mycombogrid;
		},
		
		/**
		 * 初始化相应的datagrid
		 * @param {Object} param
		 * @param.domid {String} 必须传入domid
		 * @param.placeholder {String} input默认提示信息
		 * @param.verify {String} layui验证
		 * @param.className {String} input样式名称
		 * @param.textFieldValue {String} 必须传input对应的列名
		 * @param.columnsData {String} 必须传input对应的列名
		 * @param.loadDatafun {String} 数据加载函数
		 * @param.func {String} 回调函数
		 * @param.url  {String} 必须传 数据加载url
		 * @param.code {String} 配置加载通用字典的分类
		 */
		initDatagridInput:function(param){
			try{
				param.url = param.url ? param.url : '';
				param.height = param.height ? param.height :'auto';
				param.className = param.className ? param.className : '';
				param.verify = param.verify ? param.verify : '';
				param.placeholder = param.placeholder ? param.placeholder : '';
				var mycombogrid = new Combogrid();
				mycombogrid.init({
				    // 对应要转换为控件的dom对象
				    dom: $('#'+param.domid)[0],
				    verify:param.verify,
				    placeholder:param.placeholder,
				    className:param.className,
				    datagrid: {
				        // 弹出表格的宽度单位PX
				        width: '100%',
				        height:param.height,
				        // 写入input对应的列名
				        textField: param.textFieldValue,
				        // 列设置其中align有（left、center、right）
				        columns: param.columnsData,
				        pagelist:["firstPage","prePage","pageInfo","nextPage","lastPage"],
				        // 加载成功回调函数
				        loadSuccess: function(keyword, pageNum, pageSize) {
				        	if(keyword){
								var tPageSize = pageSize;
								var params = {
										rn_s: (pageNum - 1) * (tPageSize) + 1 + '',
										rn_e: pageNum * (tPageSize) + '',
										jsm: keyword
								};
								var	returndata = "";
								params.config_param = param;
								if(typeof param.loadDatafun === "function") { //是函数    其中 FunName 为函数名称
			                    	returndata = param.loadDatafun(param.url, params);
				                } else { //不是函数
				                    returndata = eval(param.loadDatafun+"('"+param.url+"',"+JSON.stringify(params)+")");
		                		}
									if(returndata){
										if(returndata.length == 0) {
										layer.msg('未检索到数据', {
											time: 1500
										});
										return;
									}
									//传入页码信息
									var pageInfo = {
											pageNum: pageNum,
											pageSize: pageSize,
											totalPage: Math.ceil(returndata[0].total / tPageSize)
										}
										// 绑定数据
										// 加载完成写入数据
									mycombogrid.setData(returndata, pageInfo);
								}
								
							}
				        },
				        // 行选中回调函数
				        selectRow: function(rowData) {
				        	if(typeof param.func === "function") { //是函数    其中 FunName 为函数名称
		                    	param.func(rowData);
			                } else { //不是函数
			                    eval(param.func+"("+JSON.stringify(rowData)+")");
	                		}
				        	
				        }
				    }
				
				});
				return mycombogrid;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 特殊设置联动下拉的值，处理赋值和渲染的先后问题
		 * @param {Object} dom
		 * @param {Object} value
		 */
		setLdSelectValue:function(dom,value){
			try{
				var domObj = $("#"+dom)[0];
				//第一步 ： 判断是否渲染
				if($("#"+dom).find("option[value != '']").size()<1){
					//第二步：渲染后直接赋值，未渲染，把值绑定在dom上，在渲染的时候把值赋给select
					if(domObj){
						domObj.selectvalue = value;
					}
				}else{
					
					$("#"+dom).val(value);
				}
			}catch(e){
				//TODO handle the exception
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 
		 * @param {ture 不可读，false 可读} type 
		 */
		emptyLdSelect:function(type){
			try{
				$(".hkdz-selector select,.hkdz-selector input[id]").each(function(i,ele){
					if(i > 0){
						if(ele.tagName.toLocaleLowerCase()=='input'){
							if(type){
								$(ele).val("").attr("readonly","readonly");
							}else{
								$(ele).removeAttr("readonly","readonly");
							}
						}else if(ele.tagName.toLocaleLowerCase()=='select'){
							if(type){
								$(ele).val("").attr("disabled","disabled");
							}else{
								$(ele).removeAttr("disabled","disabled");
							}
						}
					}
				});
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		onHkdzzSelect:function(dom,dom_value){
			try{
				var index = $(".hkdz-selector select").index(dom);
				//获取对应的select
				var target_dom = $(".hkdz-selector select").eq(index+4);
				$(target_dom).val(dom_value);
				//获取相应
				var target_child_id = $(target_dom).attr("load-child-dom");
				$(target_dom).removeAttr("disabled");
				//
				commonUtil.loadXzqhBySjdm(dom_value,target_child_id,"old");
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 加载市代码，浙江
		 */
		loadXzqhShi : function(domid){
			try{
				var data = commonUtil.getXzqhShi();
				var param = {};
				param.domid = domid;
				param.data = data;
				param.pleaseselect = '1';
				commonUtil.loadDic(param);
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 选中区划   后加载区划下的医院
		 * @param {Object} xzqh  区划
		 * @param {Object} domid domid
		 * @param {String} lx new代表初始化，old代表下拉操作
		 */
		loadYyByXzqh:function(xzqh, domid, lx){
			var data = commonUtil.getYyByXzqh(xzqh);
			var param_sj = {};
			param_sj.domid = domid;
			param_sj.data = data;
			//在这里获取当期domid selectValue 判断是否进行过赋值 进行过赋值就选择赋值的内容
			var domobj = $("#"+domid)[0];
			if(domobj){
				var selectvalue = $("#"+domid)[0].selectvalue;
				if(selectvalue && lx == "new"){
					param_sj.selectvalue = selectvalue;
				}
			}
			commonUtil.loadDic(param_sj);
			form.render('select');
		},
		/**
		 * 选中区划   后加载下级区划
		 * @param {Object} xiandm
		 * @param {Object} domid
		 * @param {String} lx new代表初始化，old代表下拉操作
		 */
		loadXzqhBySjdm:function(sjdm,domid,lx){
			try{
				var data = commonUtil.getXzqhBySjdm(sjdm);
				var param_sj = {};
				param_sj.pleaseselect = '1';
				param_sj.domid = domid;
				param_sj.data = data;
				//在这里获取当期domid selectValue 判断是否进行过赋值 进行过赋值就选择赋值的内容
				var domobj = $("#"+domid)[0];
				if(domobj){
					var selectvalue = $("#"+domid)[0].selectvalue;
					if(selectvalue && lx == "new"){
						param_sj.selectvalue = selectvalue;
					}
				}
				commonUtil.loadDic(param_sj);
				form.render('select');
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 
		 * 处理联动下拉框在数据加载时的下一级的渲染初始化
		 * 现在分成两张类型  一种是依据上级区划加载下级区划  qh 一种是 下载区划下的医院yy 默认加载qh
		 * @param {Object} domid
		 * @param {Object} value
		 */
		inintLdSelect:function(domid,value){
			try{
				//通过当期id 查找需要渲染的下级id
				var child_dom = $("#"+domid).attr("load-child-dom");
				//由于多了依据区划加载医院 多添加了一个属性
				if(child_dom != "" && child_dom){
						//下级id 不为空 渲染下级  获取渲染类型
						var load_lx = $("#"+domid).attr("load-data-lx");
						if(load_lx != "" && load_lx == "yy"){
							commonUtil.loadYyByXzqh(value,child_dom,"new");
						}else{
							commonUtil.loadXzqhBySjdm(value,child_dom,"new");
						}
						return true;
				}else{
						//没有下级id 不执行 直接返回
						return false;
				}
			}catch(e){
				//TODO handle the exception
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 将报告卡数据绑定在form表单上
		 * @param {Object} data
		 */
		setFromData:function(data){
			try{
					/*实现逻辑：1、遍历表单数据对象
					   2、依据对象属性即表单的name或者id获取是input select checkbox radio标签
					   3、特殊处理chexbox和联动下拉的赋值操作
					   */
				for(var keyword in data){
					if($("[name='"+keyword+"']").length > 0){
						var tagName = $("[name='"+keyword+"']")[0].tagName.toLowerCase();
						if(tagName == "input"){
							var type = $("[name='"+keyword+"']").attr("type");
							if(type == "checkbox"){
								if(data[keyword]){
									var arrValue = data[keyword].split(",");
									if(arrValue && arrValue.length>0){
										for(var i = 0; i < arrValue.length;i++){
											$("[name='"+keyword+"'][value='"+arrValue[i]+"']").prop("checked",true);
										}
									}
								}
							}else if(type == "radio"){
								$("[name='"+keyword+"'][value='"+data[keyword]+"']").prop("checked",true);
							}else{
								$("[name='"+keyword+"']").val(data[keyword]);
							}
						}else if(tagName == "select"){
							//特殊处理  联动选择框 问题是一定要先加载后渲染，现在存在
								commonUtil.setLdSelectValue(keyword,data[keyword]);
								//渲染下级机构，但是没有处理是否赋值过了
								var swtich = commonUtil.inintLdSelect(keyword,data[keyword]);
								if(swtich){
									commonUtil.setLdSelectValue(keyword,data[keyword]);
								}else{
									$("[name='"+keyword+"']").val(data[keyword]);
								}
						}else if(tagName == "textarea"){
							var value = data[keyword] ? data[keyword] :"";
							$("[name='"+keyword+"']").text(value);
						}else{
							continue;
						}
						
					}
				}
				form.render();
			}catch(e){
				//TODO handle the exception
				commonUtil.openErrorTracePanel(e);
			}
			
		},
		/**
		 * 设置表单不可以编辑
		 */
		setNoEditorFrom:function(domid){
			try{
				// checkbox 设置 disable
				// radio 设置 disable
				// 简单给input 设置上 readonly
				$("#"+domid+" input").each(function(index,ele){
					var typename= $(ele).attr("type");
					if(typename != "text" && typename != "hidden"){
						$(ele).attr("disabled","disabled");
					}else{
						$(ele).attr("readonly","readonly");
					}
				});
				
				$("#"+domid+" select").each(function(index,ele){
					$(ele).attr("disabled","disabled");
				});
				
				form.render();
			}catch(e){
				//TODO handle the exception
				commonUtil.openErrorTracePanel(e);
			}
		
		},
		/**
		 * 打开 带表带 的弹出层
		 * @param {String 标题名} title
		 * @param {String domid} dom
		 * @param {Array 数组形式 长度为2} btnName
		 * @param {String 点击保存执行的方法} yes_func
		 * @param {String 携带的参数} yes_params
		 * @param {String 点击保存执行的方法} colse_func
		 * @param {String 携带的参数} close_params
		 * @param {弹窗宽度} width
		 * @param {弹窗高度} height
		 */
		openDialog: function(title,dom,btnName,yes_func,yes_params,colse_func,close_params,width,height){
			var dialogWidth = '400px';
			var dialogHeight = '320px';
			var btarr = ['确认', '取消'];
			if(!title||!dom){
				commonUtil.alertShowMsg("参数有误，请重试！");
				return;
			}
			if(width && height){
				dialogWidth = width;
				dialogHeight = height;
			}
			if(btnName){
				btarr = btnName;
			}
			//弹出层初始化
	  		window.openDialogIndex = layer.open({
		        type: 1,
		        area: [dialogWidth, dialogHeight],
		        shade: [0.8, '#393D49'],
		        title: title,
		        btnAlign: 'c',
		        content: $('#'+dom),
		        btn: btarr,
				yes: function(index, layero){
					var funStr = '';
					if(yes_func && yes_func != ""){
						funStr = yes_func+"("
						if(yes_params && yes_params != ""){
							funStr = funStr+yes_params+")";
						}else{
							funStr = funStr+")";
						}
						eval(funStr);
					}
					
			 	},
			  	btn2: function(index, layero){
			  		var funStr = '';
					if(colse_func && colse_func != ""){
						funStr = colse_func+"("
						if(close_params && close_params != ""){
							funStr = funStr+close_params+")";
						}else{
							funStr = funStr+")";
						}
						eval(funStr);
					}
			  	},
			  	cancel: function(){ 
			  	}
		   });
	  	},
	  	/**
	  	 * alert形式的提示消息
	  	 * @param {Object} msg
	  	 */
	  	alertShowMsg: function(msg) {
	  		layer.alert(msg, {icon: 6});
	  	},
	  	/**
	  	 * 加载等待遮罩
	  	 */
	  	openloadshade: function() {
			var loadings = layer.load(2, {
				shade: [0.1, '#000']
			});
			return loadings;
		},
		/**
		 * msg形式的提示消息
		 * @param {Object} msg
		 */
	  	showMsg: function(msg) {
	  		layer.msg(msg, {
	  			time: 1500
	  		});
	  	},
	  	/**
		 * msg形式的讯问框
		 * @param {Object} msg
		 * @param {fuc} cb 确认的回调方法
		 */
	  	showMsgConfirm: function(msg,cb) {
	  		layer.msg(msg, {
			  	time: 0 
			  	,btn: ['确认', '取消']
			  	,yes: function(){
			  		cb();
			  	}
			});
	  	},
	  	/**
		 * alert形式的询问框
		 * @param {Object} msg
		 * @param {fuc} cb 确认的回调方法
		 */
	  	showAlertConfirm:function(title,cb){
	  		layer.alert(title,{
	  			time: 0 
			  	,btn: ['确认', '取消']
			  	,yes: function(){
			  		if(typeof cb == 'function'){
			  			cb();
			  		}else{
			  			eval(cb);
			  		}
			  		
			  	}
	  		});
	  	},
	  	/**
		 * 吐丝提示消息
		 */
	  	showTrip:function(title,dom,fx){
	  		layer.tips(title, dom, {
						tips: fx,
						time: 800
					});
	  	},
		/**
		 * 构建layui-select
		 * @param {Object} param
		 */
		loadDic : function(param){
			try{
				var datas = param.data;
				var domid = param.domid;
				var code = "code";
				var name = "name";
				var selectvalue = "";  //默认选中值
				var selectFirst = "0"; //默认选中第一性
				var pleaseselect = ""; //添加请选择选项
				var filter_arr = param.filter;//需要过滤的选项
				if(param.code){
					code = param.code;
				}
				if(param.name){
					name = param.name;
				}
				//选中第一项
				if(param.selectFirst){
					selectFirst = param.selectFirst;
				}
				//选中指定项
				if(param.selectvalue){
					selectvalue = param.selectvalue;
					selectFirst = "0";
				}
				//添加请选择
				if(param.pleaseselect){
					pleaseselect = param.pleaseselect;
				}
				//清除optin
				$("#"+domid).find('option[data]').remove();
				if(pleaseselect == '1'){//添加请选择选项
					$("#"+domid).find('option[value=""]').remove();
					$("#"+domid).append('<option value="">请选择</option>');
				}
				if(datas){
					for(var i = 0; i < datas.length; i++){
						var data = JSON.stringify(datas[i]);
						if($.inArray(datas[i][code], filter_arr) >=0){//过滤下拉选项
							continue;
						}
						if(selectFirst == '1' && i == 0){//选中首选项
							$("#"+domid).append('<option selected="selected" data=' + data + ' value="' + datas[i][code] + '">' + datas[i][name] + '</option>');
							continue;
						}
						if(selectvalue == datas[i][code]){//选中默认值
							$("#"+domid).append('<option selected="selected" data=' + data + ' value="' + datas[i][code] + '">' + datas[i][name] + '</option>');
							continue;
						}
						$("#"+domid).append('<option data=' + data + ' value="' + datas[i][code] + '">' + datas[i][name] + '</option>');
					}
				}
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 构建layui-select
		 * @param {Object} param
		 */
		newLoadDic : function(param){
			try{
				var datas = param.data;
				var select = param.select;
				var code = "code";
				var name = "name";
				var selectvalue = "";  //默认选中值
				var selectFirst = "0"; //默认选中第一性
				var pleaseselect = ""; //添加请选择选项
				var filter_arr = param.filter;//需要过滤的选项
				if(param.code){
					code = param.code;
				}
				if(param.name){
					name = param.name;
				}
				//选中第一项
				if(param.selectFirst){
					selectFirst = param.selectFirst;
				}
				//选中指定项
				if(param.selectvalue){
					selectvalue = param.selectvalue;
					selectFirst = "0";
				}
				//添加请选择
				if(param.pleaseselect){
					pleaseselect = param.pleaseselect;
				}
				//清除optin
				$(select).find('option[data]').remove();
				if(pleaseselect == '1'){//添加请选择选项
					$(select).find('option[value=""]').remove();
					$(select).append('<option value="">请选择</option>');
				}
				if(datas){
					for(var i = 0; i < datas.length; i++){
						var data = JSON.stringify(datas[i]);
						if($.inArray(datas[i][code], filter_arr) >=0){//过滤下拉选项
							continue;
						}
						if(selectFirst == '1' && i == 0){//选中首选项
							$(select).append('<option selected="selected" data=' + data + ' value="' + datas[i][code] + '">' + datas[i][name] + '</option>');
							continue;
						}
						if(selectvalue == datas[i][code]){//选中默认值
							$(select).append('<option selected="selected" data=' + data + ' value="' + datas[i][code] + '">' + datas[i][name] + '</option>');
							continue;
						}
						$(select).append('<option data=' + data + ' value="' + datas[i][code] + '">' + datas[i][name] + '</option>');
					}
				}
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 构建layui-select
		 * 用于异步加载下拉选，如果默认项不在字典内，则添加此项
		 * @param {Object} param
		 */
		loadDicAsyn : function(param){
			try{
				var datas = param.data;
				var domid = param.domid;
				var code = "code";
				var name = "name";
				var code_default = "";  //默认的字典code
				var name_default = param.name_default;  //默认的字典name
				var selectFirst = "0"; //默认选中第一性
				var filter_arr = param.filter;//需要过滤的选项
				if(param.code){
					code = param.code;
				}
				if(param.name){
					name = param.name;
				}
				//选中指定项
				if(param.code_default){
					code_default = param.code_default;
				}
				//添加请选择
				if(param.pleaseselect){
					pleaseselect = param.pleaseselect;
				}
				//清除optin
				$("#"+domid).find('option[data]').remove();
				var defaultFlag = true;
				if(datas){
					//请选择的对象
					var firstDom = $("#"+domid).find('option[value=""]');
					for(var i = datas.length-1; i >= 0; i--){
						var data = JSON.stringify(datas[i]);
						if($.inArray(datas[i][code], filter_arr) >=0){//过滤下拉选项
							continue;
						}
						//如果循环时检测到已有默认选项
						var selected = $("#"+domid).find('option[opition-default="true"]');
						if(selected.length && selected.attr("value")==datas[i][code]){
							selected.remove();
							firstDom.after('<option selected="selected" opition-default="false" data=' + data + ' value="' + datas[i][code] + '">' + datas[i][name] + '</option>');
							defaultFlag = false;
							continue;
						}
						if(code_default == datas[i][code]){//选中默认值
							firstDom.after('<option selected="selected" data=' + data + ' value="' + datas[i][code] + '">' + datas[i][name] + '</option>');
							defaultFlag = false;
							continue;
						}
						firstDom.after('<option data=' + data + ' value="' + datas[i][code] + '">' + datas[i][name] + '</option>');
					}
					//如果没检测到正确的默认选项，删除此选项
					$("#"+domid).find('option[opition-default="true"]').remove();
				}
				//添加原列表没有的默认项
				if(code_default && defaultFlag && name_default){
					$("#"+domid).append('<option selected="selected" data=' + data + ' value="' + code_default + '">' + name_default + '</option>');
				}
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 给字典增加默认选项
		 * @param {Object} domid
		 * @param {Object} defaultCode
		 * @param {Object} defaultName
		 */
		loadDicAddDefault : function(domid,defaultCode,defaultName){
			try{
				var domObj = $("#"+domid);
				if(defaultCode){
					var selected = domObj.find('option[value="'+defaultCode+'"]');
					if(selected.length>0){
						domObj.val(defaultCode);
					} else {
						$("#"+domid).append('<option selected="selected" opition-default="true" value="' + defaultCode + '">' + defaultName + '</option>');
					}
				}
				form.render('select');
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 根据字典类别获取通用字典
		 * @param {Object} diccode
		 */
		getDicByDicCode : function(diccode){
			try{
				var dicdata = [];
				if(parent.index && parent.index.getDicByCode){
					//首先取index页面缓存
					dicdata = parent.index.getDicByCode(diccode);
				}else if(parent.parent.index && parent.parent.index.getDicByCode){
					//首先取index页面缓存
					dicdata = parent.parent.index.getDicByCode(diccode);
				}else if(parent.personInfo && parent.personInfo.getDicByCode){
					//取数据库
					dicdata = parent.personInfo.getDicByCode(diccode);
				} else {
					//取数据库
					dicdata = commonDic.getDicByCode(diccode);
				}
				return dicdata;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 根据代码获取对应代码值
		 * @param {Object} code 字典码
		 * @param {Object} value 代码
		 * @param {Object} type 类型 1-单选值 2-多选值
		 */
		getNameByCode:function(code,value,type){
			if(!value||!type||!code){
				return '';
			}
			var codes = commonUtil.getDicByDicCode(code);
			if(type==1){
				var arr = $.grep(codes,function(data,index){
					return data.code==value;
				});
				return arr[0].name;
			}
			if(type==2){
				var result ='';
				var arr = $.grep(codes,function(data,index){
					return (','+value+',').indexOf(','+data.code+',')>=0;
					 
				});
				$.each(arr,function(index,data){
					result = result+data.name+',';
				});
				if(result.length>0){
					result = result.substr(0,result.length-1);
				}
				return result;
			}
		},
		/**
		 * 根据分类查询药品
		 * @param {Object} ypfl
		 */
		getYpByCode : function(ypfl){
			try{
				var ypdata = [];
				if(parent.parent.index && parent.parent.index.getYpByCode){
					//首先取index页面缓存
					ypdata = parent.parent.index.getYpByCode(ypfl);
				} else if(parent.index && parent.index.getYpByCode){
					//首先取index页面缓存
					ypdata = parent.index.getYpByCode(ypfl);
				}else {
					//取数据库
					ypdata = commonDic.getYpByCode(ypfl);
				}
				return ypdata;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 弹出提示信息
		 * @param {Object} title
		 * @param {Object} msg
		 * @param {Object} type
		 */
		openMsgBox:function(title, msg, type){
			try{
				layer.alert(msg);
			}catch(e){
				JsErrorTrace(e);
			}
		},
		/**
		 * 获取行政区划市
		 */
		getXzqhShi : function(){
			try{
				var dicdata = [];
				if(parent.index && parent.index.getXzqhShi){
					//首先取index页面缓存
					dicdata = parent.index.getXzqhShi();
				}else{
					//取数据库
					dicdata = commonDic.getXzqhShi();
				}
				return dicdata;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 根据上级代码获取行政区划
		 * @param {Object} sjdm
		 * @param {Object} callback 异步加载回调
		 */
		getXzqhBySjdm : function(sjdm,callback){
			var dicdata = [];
			//首先取index页面缓存
			if(parent.index && parent.index.getXzqhBySjdm){
				dicdata = parent.parent.index.getXzqhBySjdm(sjdm,callback);
			}else if(parent.parent.index && parent.parent.index.getXzqhBySjdm){
				dicdata = parent.parent.index.getXzqhBySjdm(sjdm,callback);
			}else{
				//取数据库
				dicdata = commonDic.getXzqhBySjdm(sjdm,callback);
			}
			return dicdata;
		},
		/**
		 * 根据行政区划获取医院
		 * @param {Object} xzqh
		 */
		getYyByXzqh : function(xzqh){
			var dicdata = [];
			if(parent.index && parent.index.getYyByXzqh){
				//首先取index页面缓存
				dicdata = parent.index.getYyByXzqh(xzqh);
			}else{
				//取数据库
				dicdata = commonDic.getYyByXzqh(xzqh);
			}
			return dicdata;
		},
		/**
		 * 根据行政区划获取社区医院
		 * @param {Object} xzqh
		 */
		getSqYyByXzqh : function(xzqh){
			var dicdata = [];
			if(parent.index && parent.index.getSqYyByXzqh){
				//首先取index页面缓存
				dicdata = parent.index.getSqYyByXzqh(xzqh);
			}else{
				//取数据库
				dicdata = commonDic.getSqYyByXzqh(xzqh);
			}
			return dicdata;
		},
		/**
		 * 获取所有机构信息
		 * @param {Object} diccode
		 */
		getJgxx : function(){
			try{
				var dicdata = [];
				if(parent.parent.index && parent.parent.index.getDicByCode){
					//首先取index页面缓存
					dicdata = parent.parent.index.getJgxx();
				}else if(parent.index && parent.index.getDicByCode){
					//首先取index页面缓存
					dicdata = parent.index.getJgxx();
				}else{
					//取数据库
					dicdata = commonDic.getJgxx();
				}
				return dicdata;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 打开正在加载
		 */
		layerLoading : function(){
			//打开遮罩
			var loadings = layer.load(2, {
			  	shade: [0.1,'#000'] 
			});
			return loadings;
		},
		/**
		 * 关闭正在加载
		 * @param {Object} loadings
		 */
		layerCloseLoading : function(loadings){
			//关闭遮罩
			layer.close(loadings);
		},
		/**
		 * 加载单选框
		 * @param {Object} param
		 */
		loadRadio : function(param){
			var datas = param.data;
			var domid = param.domid;
			var parentid = param.parentid;
			var disabled = param.disabled;
			var code = "code";
			var name = "name";
			var selectvalue = "";  //默认选中值
			if(param.selectvalue){
				selectvalue = param.selectvalue;
			}
			var filter_arr = param.filter;//需要过滤的选项)
			//是否必填
			var required = "";
			var required_title = "";
			if(param.required == 'required'){
				required = 'required';
			}
			if(param.required_title){
				required_title = param.required_title;
			}
			//清除optin
			$("#"+parentid).find('input:radio[data]').remove();
			if(datas){
				for(var i = 0; i < datas.length; i++){
					var data = JSON.stringify(datas[i]);
					if($.inArray(datas[i][code], filter_arr) >=0){//过滤下拉选项
						continue;
					}
					if(selectvalue == datas[i][code]){//选中默认值
						$("#"+parentid).append('<input type="radio" lay-verify="'+ required +'" lay-verify-name="'+ required_title +'" name="'+ domid +'" value="' + datas[i][code] + '" title="'+ datas[i][name] +'" checked="checked" lay-filter="'+ domid +'">');
						continue;
					}
					if(disabled){
						$("#"+parentid).append('<input type="radio" lay-verify="'+ required +'" lay-verify-name="'+ required_title +'" name="'+ domid +'" value="' + datas[i][code] + '" title="'+ datas[i][name] +'" lay-filter="'+ domid +'" disabled>');
						continue;
					}
					$("#"+parentid).append('<input type="radio" lay-verify="'+ required +'" lay-verify-name="'+ required_title +'" name="'+ domid +'" value="' + datas[i][code] + '" title="'+ datas[i][name] +'" lay-filter="'+ domid +'">');
				}
			}
		},
		/**
		 * 加载复选框
		 * @param {Object} param
		 */
		loadCheckbox : function(param){
			var datas = param.data;
			var domid = param.domid;
			var parentid = param.parentid;
			var code = "code";
			var name = "name";
			var selectvalue = "";  //默认选中值
			//是否必填
			var required = "";
			var required_title = "";
			if(param.required == 'required'){
				required = 'required';
			}
			if(param.required_title){
				required_title = param.required_title;
			}
			if(param.selectvalue){
				selectvalue = ',' + param.selectvalue + ',';
			}
			var filter_arr = param.filter;//需要过滤的选项)
			//清除optin
			$("#"+parentid).find('input:checkbox[data]').remove();
			if(datas){
				for(var i = 0; i < datas.length; i++){
					var data = JSON.stringify(datas[i]);
					if($.inArray(datas[i][code], filter_arr) >=0){//过滤下拉选项
						continue;
					}
					if(selectvalue.indexOf(',' + datas[i][code] + ',') >= 0){//选中默认值
						$("#"+parentid).append('<input type="checkbox" lay-verify="'+ required +'" lay-verify-name="'+ required_title +'"  name="'+ domid +'" value="' + datas[i][code] + '" title="'+ datas[i][name] +'" checked="checked" lay-skin="primary"  lay-filter="'+ domid +'">');
						continue;
					}
					$("#"+parentid).append('<input type="checkbox" lay-verify="'+ required +'" lay-verify-name="'+ required_title +'"  name="'+ domid +'" value="' + datas[i][code] + '" title="'+ datas[i][name] +'" lay-skin="primary" lay-filter="'+ domid +'">');
				}
			}
		},
		/**
		 * 用于复选框有 "无"选项的联动监听事件，并且可以联动其他的元素
		 * checkbox 复选框内的"无"选项，勾选隐藏联动监听事件，会重新渲染checkbox
		 * @param {Object} domName checkbox name 属性
		 * @param {Object} noCode "无"选项 的code
		 * @param {Object} fldm 加载的字典分类代码
		 * @param {Object} hideCode 联动隐藏其他div得class 可选
		 * @param {Object} hideDomClass 联动其他dom的class 可选
		 * @param {Object} hideDomRequired 联动其他dom里的元素是否必填
		 * @param {Object} callback 回调函数
		 */
		checkboxHideLd : function(domId,noCode,fldm,hideCode,hideDomClass,hideDomRequired,callback){
			form.on('checkbox('+domId+')',function(data){
				if(data.value==noCode || data.value==hideCode){
					var value = ","+commonUtil.getCheckBoxValue(domId)+",";
					if(hideCode){
						if(value.indexOf(","+hideCode+",")>=0 && value.indexOf(","+noCode+",")=="-1"){
							$("."+hideDomClass).show();
							if(hideDomRequired){
								$("."+hideDomClass).find("input").attr("lay-verify","required");
							}
						} else {
							$("."+hideDomClass).hide();
							$("."+hideDomClass).find("input").val("");
							if(hideDomRequired){
								$("."+hideDomClass).find("input").removeAttr("lay-verify");
							}
						}
					}
					if(data.value==noCode){
						var param_data = commonUtil.getDicByDicCode(fldm);
						var required = $(data.elem).attr("lay-verify");
						var required_title = $(data.elem).attr("lay-verify-name");
						var params = {};
						//重新渲染checkbox
						if(value.indexOf(","+noCode+",")>=0){//如果选中无，则，只加载这项数据，并设置选中
							params.selectvalue = noCode;
							for(var i in param_data){
								if(param_data[i].code == noCode){
									var param_data_temp = [];
									param_data_temp.push(param_data[i]);
									param_data = param_data_temp;
									break;
								}
							}
						} else{//如果不选中无，则加载全部选项，不默认勾选
							params.selectvalue = '';
						}
						$("#"+domId+"_div").html("");
						params.domid = domId;
						params.parentid = domId+"_div";
						params.data = param_data;
						params.required = required;
						params.required_title = required_title;
						commonUtil.loadCheckbox(params);
						form.render('checkbox');
					}
				}
				if(callback){
					callback(data);
				}
			});
		},
		/**
		 * 用于复选框有 "无"选项的初始化，对应checkboxHideLd
		 * checkbox 复选框内的"无"选项，勾选隐藏联动监听事件，会重新渲染checkbox
		 * @param {Object} domName checkbox name 属性
		 * @param {Object} data 传入数据
		 * @param {Object} noCode "无"选项 的code
		 * @param {Object} fldm 加载的字典分类代码
		 * @param {Object} hideCode 联动隐藏其他div得class 可选
		 * @param {Object} hideDomClass 联动其他dom的class 可选
		 * @param {Object} hideDomRequired 联动其他dom里的元素是否必填
		 * @param {Object} callback 回调函数
		 */
		initCheckboxHideLd : function(domId,data,noCode,fldm,hideCode,hideDomClass,hideDomRequired,callback){
			//其他dom的显示隐藏
			if(hideCode && data[domId] && (","+data[domId]+",").indexOf(","+hideCode+",")>=0){
				$("."+hideDomClass).show();
				if(hideDomRequired){
					$("."+hideDomClass).find("input").attr("lay-verify","required");
				}
			} else if(hideCode){
				$("."+hideDomClass).hide();
				if(hideDomRequired){
					$("."+hideDomClass).find("input").removeAttr("lay-verify");
				}
			}
			if(data[domId] && (","+data[domId]+",").indexOf(","+noCode+",")>=0){
				var param_data = commonUtil.getDicByDicCode(fldm);
				var required = $("#"+domId+"_div").find("input").attr("lay-verify");
				var required_title = $("#"+domId+"_div").find("input").attr("lay-verify-name");
				var params = {};
				//重新渲染checkbox
				for(var i in param_data){
					if(param_data[i].code == noCode){
						var param_data_temp = [];
						param_data_temp.push(param_data[i]);
						param_data = param_data_temp;
						break;
					}
				}
				$("#"+domId+"_div").html("");
				params.domid = domId;
				params.parentid = domId+"_div";
				params.data = param_data;
				params.selectvalue = noCode;
				params.required = required;
				params.required_title = required_title;
				commonUtil.loadCheckbox(params);
				form.render('checkbox');
			}
			if(callback){
				callback(data);
			}
		},
		/**
		 * 获取json文件格式
		 */
		//获取index首页的菜单
		getIndexMenu : function(key,url){
			try{
				var path = window.document.location.href;  
				var index_length = path.indexOf('jwythglxt');
				path = path.substr(0, index_length + 9);
				url = path + url;
				var returndata = "";
				$.ajax({
		            type: "GET",
		            async: false,
		            dataType: "json",
		            url: url,
		            cache: false,
		            success: function (data) {
		              		returndata = data[key];
		            },
		            error: function (err) {
		                alert('获取数据服务器地址出错');
		                return;
		            }
		        });
		        return returndata;
			}catch(e){
		    	commonUtil.openErrorTracePanel(e);
		    }
		},
		/**
		 * 获取chekbox的值
		 * @param {Object} name
		 */
		getCheckBoxValue:function(name){
			try{
				var length = $("[name = '"+name+"']").length;
				var str = "";
				if(length > 0){
					$("[name = '"+name+"']").each(function(index,ele){
						if($(ele).prop("checked")){
							var value =  $(ele).val();
							str = str + "," + value;
						}
					});
					if(str){
						str = str.substring(1);
					}
				}
				return str;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 获取chekbox的文本
		 * @param {Object} name
		 */
		getCheckBoxText:function(name){
			try{
				var length = $("[name = '"+name+"']").length;
				var str = "";
				if(length > 0){
					$("[name = '"+name+"']").each(function(index,ele){
						if($(ele).prop("checked")){
							var title =  $(ele).attr("title");
							str = str + "," + title;
						}
					});
					if(str){
						str = str.substring(1);
					}
				}
				return str;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 获取单选框的值
		 * @param {Object} name
		 */
		getRadioValue:function(name){
			try{
				var str = $("input[type='radio'][name = '"+name+"']:checked").val();
				return str;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 获取下拉选的文本
		 * @param {Object} name
		 */
		getSelectText:function(name){
			try{
				var str = $("select[name = '"+name+"']").next().find('dd[class="layui-this"]').html();
				return str;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 创建按钮，通过lx 生成不同按钮，控制权限问题
		 * @param {Object} lx look 查看  edit 修改  del 删除， checked 审核 unchecked 不审核 
		 * @param {String} clickFun 点击事件的处理函数
		 * @param {Object} fun_param 函数参数 放对象
		 */
		genrateButton:function(lx,click_fun,fun_param){
			try{
				var save = '<button class="layui-btn layui-btn-normal layui-btn-sm btn" id="bt_save" onclick="'+click_fun+'('+fun_param+')" lay-filter="bt_save">保存</button>';
				var checked = '<button class="layui-btn layui-btn-sm btn" id="bt_check" onclick="'+click_fun+'('+fun_param+')" lay-filter="bt_check">审核通过</button>';
				var unchecked = '<button class="layui-btn layui-btn-sm btn" id="bt_uncheck" onclick="'+click_fun+'('+fun_param+')" lay-filter="bt_uncheck">审核不通过</button>';
				var del = '<button class="layui-btn layui-btn-danger layui-btn-sm btn" id="bt_del" onclick="'+click_fun+'('+fun_param+')" lay-filter="bt_del">删除</button>';
				var str = '';
				if(lx == "save"){
					str = save;
					$(".button-group-container-fiex").show();
				}else if(lx == "checked"){
					//通过 不通过
					str = checked;
					$(".button-group-container-fiex").show();
				}else if(lx =="unchecked" ){
					str = unchecked;
				}
				else if(lx == "del"){
					str = del;
					$(".button-group-container-fiex").show();
				}else if(lx == "look"){
					str = '';
					$(".button-group-container-fiex").hide();
				}
				$(".button-group-container-fiex").append(str);
			}catch(e){
				//TODO handle the exception
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 设置user所在市  单一 不可多选
		 * @param {Object} user
		 * @param {Object} param
		 */
		setChildJgdmBysjdm:function(code,domid){
			try{
				var dicdata = [];
				if(parent.index && parent.index.getXzqhShi_Czysz){
					//首先取index页面缓存
					dicdata = parent.index.getXzqhShi_Czysz(code);
				}else{
					//取数据库
					dicdata = commonDic.getXzqhShi_Czysz(code);
				}
				var param_select = {};
				param_select.domid = domid;
				param_select.data = dicdata;
				commonUtil.loadDic(param_select);
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
			
		},
		/**
		 * 设置忽略dom  监听到下拉选中时不选择下级
		 * @param {Object} domid
		 */
		setLayIgnore:function(domid){
			try{
				$("#"+domid).prop("lay_ignore",true);
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 设置联动下拉的不可选中状态
		 */
		setNotSelect:function(domid){
			try{
				$("#"+domid+" select,#"+domid+" input").each(function(index,item){
					var value = $(item).val();
					if(value == "" && $(item)[0].nodeName == "SELECT"){
						$(item).attr("disabled","disabled");
					}else if(value == "" && $(item)[0].nodeName == "INPUT"){
						$(item).attr("readonly","readonly");
					}
				});
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 加载医院列表依据上级id
		 * @param {Object} domid
		 */
		setJzyyBysjXzqh:function(domid){
			try{
//				$("#"+domid).prop("lay_ignore",true);
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		getUserXzqh:function(user){
			try{
				var return_info = {};
				if(user.jgjb == "2"){
					//市
					return_info.shixzqh = user.xzqh;
				}else if(user.jgjb =="3"){
					//区县
					return_info.shixzqh = user.xzqh.substring(0,4)+'0000';
					return_info.qxxzqh = user.xzqh.substring(0,6)+"00";
				}else if(user.jgjb =="4"){
					//街道
					return_info.shixzqh = user.xzqh.substring(0,4)+'0000';
					return_info.qxxzqh = user.xzqh.substring(0,6)+"00";
					return_info.jdxzqh =user.xzqh;
				}
				return return_info;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 加载操作员所在行政区划-下拉
		 * @param {Object} user
		 * @param {Object} param
		 */
		loadUserXzqhSelect:function(user,param){
			try{
				if(user && user.xzqh){
					//省份
					if(user.jgjb == "1"){
						if(param.shi){
							commonUtil.loadXzqhShi(param.shi);
						}
					}else if(user.jgjb == "2"){
						//市
						if(param.shi){
							var dicdata = [];
							var code = user.xzqh;
							commonUtil.setChildJgdmBysjdm(code,param.shi);
							commonUtil.setLayIgnore(param.shi);
						}
						if(param.xian){
							var dicdata = commonUtil.getXzqhBySjdm(user.xzqh);
							var param_data = {};
							param_data.domid = param.xian;
							param_data.data = dicdata;
							param_data.pleaseselect = '1';//添加请选择选项
							commonUtil.loadDic(param_data);
						}
					}else if(user.jgjb == "3"){
						//区县
						if(param.shi){
							var dicdata = [];
							var code = user.xzqh.substring(0,4)+'0000';
							commonUtil.setChildJgdmBysjdm(code,param.shi);
							commonUtil.setLayIgnore(param.shi);
						}
						if(param.xian){
							var dicdata = [];
							var code = user.xzqh.substring(0,6)+"00";
							commonUtil.setChildJgdmBysjdm(code,param.xian);
							commonUtil.setLayIgnore(param.xian);
						}
						if(param.jd){
							var dicdata = commonUtil.getXzqhBySjdm(user.xzqh.substring(0,6)+"00");
							var param_data = {};
							param_data.domid = param.jd;
							param_data.data = dicdata;
							param_data.pleaseselect = '1';//添加请选择选项
							commonUtil.loadDic(param_data);
						}
					}else if(user.jgjb == "4"){
						//街道
						if(param.shi){
							var dicdata = [];
							var code = user.xzqh.substring(0,4)+'0000';
							commonUtil.setChildJgdmBysjdm(code,param.shi);
							commonUtil.setLayIgnore(param.shi);
						}
						if(param.xian){
							var dicdata = [];
							var code = user.xzqh.substring(0,6)+"00";
							commonUtil.setChildJgdmBysjdm(code,param.xian);
							commonUtil.setLayIgnore(param.xian);
						}
						if(param.jd){
							var dicdata = [];
							var code = user.xzqh;
							commonUtil.setChildJgdmBysjdm(code,param.jd);
							commonUtil.setLayIgnore(param.jd);
						}
						if(param.yy){
							var dicdata = [{"code":user.jgdm,"name":user.username}];
							var param_data = {};
							param_data.domid = param.yy;
							param_data.data = dicdata;
							param_data.pleaseselect = '0';//不添加请选择选项
							commonUtil.loadDic(param_data);
						}
					}
				}
				
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		
		/**
		 * 获取用户查询时的管理单位，根据级别截取
		 * @param {Object} user
		 */
		getQueryUserGldw : function(user){
			if(!user){
				user = commonUtil.getUser();
			}
			if(user.jgjb == '1'){
				return user.jgdm.substr(0, 2);
			}else if(user.jgjb == '2'){
				return user.jgdm.substr(0, 4);
			}else if(user.jgjb == '3'){
				return user.jgdm.substr(0, 6);
			}else{
				return user.jgdm;
			}
		},
		/**
		 * 获取用户查询时的行政区划，根据级别截取
		 * @param {Object} user
		 */
		getQueryUserXzqh : function(user){
			if(!user){
				user = commonUtil.getUser();
			}
			if(user.jgjb == '1'){
				return user.xzqh.substr(0, 2);
			}else if(user.jgjb == '2'){
				return user.xzqh.substr(0, 4);
			}else if(user.jgjb == '3'){
				return user.xzqh.substr(0, 6);
			}else{
				return user.xzqh;
			}
		},
		/**
		 * 检查多选和单选是否必填
		 */
		checkRadioCheckboxRequared : function(){
			try{
				var res = true;
				$("input[type='radio'][lay-verify='required'],input[type='checkbox'][lay-verify='required']").each(function(i, item) {
					var name = $(item).attr('name');
					var title =  $(item).attr('lay-verify-name');
					var value = $("input[name='"+name +"']:checked").val(); 
					if(!value){
						var parentDom = $(item).parent();
						/*$(item).parent().focus().addClass('layui-form-danger')
						$(item).next().focus().addClass('layui-form-danger')
						$(item).focus().addClass('layui-form-danger');*/
						document.getElementById(parentDom.attr("id")).scrollIntoView({block: "end", inline: "nearest"});
						if($(".wrap").length){
			          		$(".wrap").animate({ scrollTop: "+=200" });//向上滚动200像素
			          	}
						parentDom.css("border","1px solid red").css("margin","-1px 0px -1px 1px");
						parentDom.on("click",function(){
							$(this).off("click");
							$(this).css("border","none").css("margin","0px 0px 0px 1px").css("border-left","1px solid #D3D7E0");
						});
						if(title){
							res = false;
							layer.msg('必填项[' + title + ']不能为空', {icon: 5, shift: 6});
						}else{
							res = false;
							layer.msg('请检查必填项是否录入完整', {icon: 5, shift: 6});
						}
						return false;
					}
				});
				return res;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 提交等待
		 * @param {Object} buttonId
		 */
		subWait : function(buttonId){
			//正在提交中
			if($("#"+buttonId).hasClass("layui-btn-disabled")){
				return;
			}
			$("#"+buttonId).addClass("layui-btn-disabled");
			$("#"+buttonId).attr('readonly', "readonly");
			//打开遮罩
			var loadings = commonUtil.layerLoading();
			return loadings;
		},
		/**
		 * 关闭提交等待
		 * @param {Object} buttonId
		 * @param {Object} loadings
		 */
		subWaitClose : function(buttonId, loadings){
			$("#"+buttonId).removeClass("layui-btn-disabled");
        	$("#"+buttonId).removeAttr('readonly');
			commonUtil.layerCloseLoading(loadings);
		},
		/**
		 * 通过上级区划加载下级
		 * @param {Object} sjdm
		 * @param {Object} domid
		 * @param {Object} lx
		 */
		loadXzqhBySjdm_select:function(sjdm, domid, selectvalue){
			try{
				var data = commonUtil.getXzqhBySjdm(sjdm);
				var param_sj = {};
				param_sj.domid = domid;
				param_sj.data = data;
				if(selectvalue){
					param_sj.selectvalue = selectvalue;
				}
				commonUtil.loadDic(param_sj);
				form.render('select');
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 获取layui-table单击选中行
		 * @param {Object} tableid
		 */
		getLayTableSelected : function(laytable, tableid){
			try{
				if(laytable && tableid){
					var rows = laytable.getRows(tableid);
					var index = $("#" + tableid).next('div.layui-table-view').find('div.layui-table-body').find('tr.zdy-table-click').attr('data-index');
					return rows[index];
				}
				return;
				
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		
		GetVerifyBit : function(id){
			try{
		    var result;
		    var nNum=eval(id.charAt(0)*7+id.charAt(1)*9+id.charAt(2)*10+id.charAt(3)*5+id.charAt(4)*8+id.charAt(5)*4+id.charAt(6)*2+id.charAt(7)*1+id.charAt(8)*6+id.charAt(9)*3+id.charAt(10)*7+id.charAt(11)*9+id.charAt(12)*10+id.charAt(13)*5+id.charAt(14)*8+id.charAt(15)*4+id.charAt(16)*2);
		    nNum=nNum%11;
		    switch (nNum) {
		       case 0 :
		          result="1";
		          break;
		       case 1 :
		          result="0";
		          break;
		       case 2 :
		          result="X";
		          break;
		       case 3 :
		          result="9";
		          break;
		       case 4 :
		          result="8";
		          break;
		       case 5 :
		          result="7";
		          break;
		       case 6 :
		          result="6";
		          break;
		       case 7 :
		          result="5";
		          break;
		       case 8 :
		          result="4";
		          break;
		       case 9 :
		          result="3";
		          break;
		       case 10 :
		          result="2";
		          break;
		    }
		    return result;
		   }catch(e){
		   	JsErrorTrace(e);
		   }
		},

		/**
		 * 校验身份证号码合法性
		 * @param {Object} obj
		 */
		checkSfzhCard: function(obj) {
			try{
				var aCity = {
					11: "北京",
					12: "天津",
					13: "河北",
					14: "山西",
					15: "内蒙古",
					21: "辽宁",
					22: "吉林",
					23: "黑龙江",
					31: "上海",
					32: "江苏",
					33: "浙江",
					34: "安徽",
					35: "福建",
					36: "江西",
					37: "山东",
					41: "河南",
					42: "湖北",
					43: "湖南",
					44: "广东",
					45: "广西",
					46: "海南",
					50: "重庆",
					51: "四川",
					52: "贵州",
					53: "云南",
					54: "西藏",
					61: "陕西",
					62: "甘肃",
					63: "青海",
					64: "宁夏",
					65: "新疆",
					71: "台湾",
					81: "香港",
					82: "澳门",
					91: "国外"
				};
				var iSum = 0;
				//var info = "";
				var strIDno = obj;
				var idCardLength = strIDno.length;
				if(!/^\d{17}(\d|x)$/i.test(strIDno) && !/^\d{15}$/i.test(strIDno))
					return 1; //非法身份证号
			
				if(aCity[parseInt(strIDno.substr(0, 2))] == null)
					return 2; // 非法地区
			
				// 15位身份证转换为18位
				if(idCardLength == 15) {
					sBirthday = "19" + strIDno.substr(6, 2) + "-" + Number(strIDno.substr(8, 2)) + "-" + Number(strIDno.substr(10, 2));
					var d = new Date(sBirthday.replace(/-/g, "/"))
					var dd = d.getFullYear().toString() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
					if(sBirthday != dd)
						return 3; //非法生日
					strIDno = strIDno.substring(0, 6) + "19" + strIDno.substring(6, 15);
					strIDno = strIDno + commonUtil.GetVerifyBit(strIDno);
					//alert(strIDno);
				}
				// 判断是否大于2078年，小于1900年
				var year = strIDno.substring(6, 10);
				if(year < 1900 || year > 2078)
					return 3; //非法生日
				//18位身份证处理
				//在后面的运算中x相当于数字10,所以转换成a
				strIDno = strIDno.replace(/X$/, "a");
			
				sBirthday = strIDno.substr(6, 4) + "-" + Number(strIDno.substr(10, 2)) + "-" + Number(strIDno.substr(12, 2));
				var d = new Date(sBirthday.replace(/-/g, "/"))
				if(sBirthday != (d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate()))
					return 3; //非法生日
				// 身份证编码规范验证
				for(var i = 17; i >= 0; i--)
					iSum += (Math.pow(2, i) % 11) * parseInt(strIDno.charAt(17 - i), 11);
				if(iSum % 11 != 1)
					return 1; // 非法身份证号
				// 判断是否屏蔽身份证
				var words = new Array();
				words = new Array("11111119111111111", "12121219121212121");
			
				for(var k = 0; k < words.length; k++) {
					if(strIDno.indexOf(words[k]) != -1) {
						return 1;
					}
				}
				return 'true';
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		//敲回车跳转焦点
		initNextInputFocus:function(formID,domID){
			$(document).on('keyup', '#'+formID +' :input', function(e) {
				if(e.keyCode == 13){
					if(e.target.tagName == 'INPUT' || e.target.tagName == 'SELECT'){
						if(domID && e.target.id==domID){
							return;
						}
						var inputs =  $(e.target).parents('#'+formID).eq(0).find(":input:not(:disabled):not([readonly])");
						var idx = inputs.index(e.target);
						var input_ = $(e.target).parent().prev();
						//如果是searchbox，回车光标不下移
						if(!input_.is('.easyui-searchbox') && !input_.is('.easyui-combogrid')){
							if (idx == inputs.length - 1) {
								if(inputs[0]){
									inputs[0].select();
								}
							} 
							else {
								inputs[idx + 1].focus();
								if(inputs[idx + 1].tagName == "INPUT"){
									if(inputs[idx + 1]){
										inputs[idx + 1].select();
									}
								}else if(inputs[idx + 1].tagName == "SELECT"){
									if(inputs[idx + 1]){
										$(inputs[idx + 1]).next().find("input").focus();
										$(inputs[idx + 1]).next().find("input").trigger("click");
									}
								}else{
									return;
								}
							}
						}
					}
				}
			});	  
		},
		//选择下拉跳转焦点
		selectedFocus : function(from, divid){
			form.on('select', function(data){
				if(!$(data.elem).attr('tzjd')){
					var inputs = $('#'+divid).find(":input:visible:not(:disabled):not([readonly])");
					var input = $(data.elem).next().find("input").eq(0);
					var idx = inputs.index(input);
					setTimeout(function(){
						if(idx == inputs.length - 1) {
							if(inputs.length > 0){
								inputs[0].select();
							}
						}else{
							inputs[idx + 1].focus();
							if(inputs[idx + 1].tagName == "INPUT"){
								inputs[idx + 1].select();
							}
						}
					},100);
				}else{
					$(data.elem).parent().parent().next('div').find(':input:visible:not(:disabled):not([readonly])').focus();
				}
			});
		},
		/**
		 * 重置查询表单
		 * @param {Object} className 表单类名
		 */
		resetFrom : function(Domid,formDom){
			try{
				if(Domid){
					$("#"+Domid).find("input,textarea").each(function(i,ele){
						var tagName = $(ele).attr("type");
						if(tagName == 'checkbox'){
							$(ele).prop('checked',false);
						}else if(tagName == 'radio'){
							$(ele).prop('checked',false);
						} else {
							$(ele).val('');
						}
					});
					$("#"+Domid+" select").val("");
					$("#"+Domid+" select[class='chosen-select']").val([]).trigger("chosen:updated");
				}
				if(formDom){
					formDom.render();
				}
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 获取客户端时间
		 * @param {Object} type
		 */
		getClientData : function(type){
			try{
			var myDate = new Date(); 
			var date_y = myDate.getFullYear();
			var date_m = (myDate.getMonth() + 1)<10?'0'+(myDate.getMonth() + 1):myDate.getMonth() + 1;
			var date_d = myDate.getDate()<10?'0'+myDate.getDate():myDate.getDate();	
			var date_ymd = date_y + '-' +date_m + '-' + date_d;
			if(type == '0'){
				return date_ymd;
			}
			var h = myDate.getHours()<10?'0' + myDate.getHours():myDate.getHours();
			var m = myDate.getMinutes()<10?'0' + myDate.getMinutes():myDate.getMinutes();
			var s = myDate.getSeconds()<10?'0' + myDate.getSeconds():myDate.getSeconds();
			date_ymd = date_ymd + ' ' + h + ":" + m + ":" + s;
			return date_ymd;
			}catch(e){
				JsErrorTrace(e);
			}
		},
		/**
		 * 获取身份证号码信息
		 * @param {Object} idcard
		 */
		getSfzhCardInfo : function(idcard){
			try{
				var data = {};
				if(idcard.length == 15){
					sBirthday = "19" + idcard.substr(6, 2) + "-" + Number(idcard.substr(8, 2)) + "-" + Number(idcard.substr(10, 2));
					var d = new Date(sBirthday.replace(/-/g, "/"))
					var dd = d.getFullYear().toString() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
					if(sBirthday != dd)
						return 3; //非法生日
					idcard = idcard.substring(0, 6) + "19" + idcard.substring(6, 15);
					idcard = idcard + commonUtil.GetVerifyBit(idcard);
				}
				var UUserCard = idcard;	
				var date = UUserCard.substring(6, 10) + "-" + UUserCard.substring(10, 12) + "-" + UUserCard.substring(12, 14); 
				data.csrq = date;
				if (parseInt(UUserCard.substr(16, 1)) % 2 == 1) {
					data.sex = '1';
				} else {
					data.sex = '2';
				} 
				var myDate = new Date(); 
				var month = myDate.getMonth() + 1; 
				var day = myDate.getDate(); 
				var age = myDate.getFullYear() - UUserCard.substring(6, 10) - 1; 
				if (UUserCard.substring(10, 12) < month || UUserCard.substring(10, 12) == month && UUserCard.substring(12, 14) <= day) { 
				age++; 
				
				} 
				data.age = age;
				data.csrq=UUserCard.substring(6, 10)+"-"+UUserCard.substring(10, 12)+"-"+UUserCard.substring(12, 14);
				return data;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 获取伤害外部原因编码
		 */
		getShjcIcd : function(icd10){
			var param = {};
			param.icd10 = icd10.toUpperCase();
			var data = commonDic.getIcd10(param);
			return data;
		},
		/**
		 * 记录日期记录
		 * @param {Object} param
		 * @param {Object} user
		 */
		setYwjlLog : function(param, user){
			if(param && user){
				var ywjllog = {};
				ywjllog.ryid = user.ryid;
				ywjllog.ryxm = user.username;
				ywjllog.ip = user.ip;
				ywjllog.jgid = user.jgid;
				//诊间随访
				var urlParams = commonUtil.getUrlParams();
				if(urlParams && urlParams.openType && urlParams.openType=="zjsf"){
					ywjllog.bz='诊间随访';
				}
				param.ywjllog = ywjllog;
			}
			return param;
		},
		/**
		 * /**
		 * 这个公共方法，设计有误，
		 * 参数代码分为String类型，对象类型
		 * 
		 * @param {Object} jgdm
		 *
		 * 通过设置报卡单位名称
		 * @param {Object} jgdm
		 */
		getBgkdwMc:function(jgdm,domid){
			try{
				var params={};
				if(typeof jgdm == 'string'){
					params.jgdm = jgdm;
				}else if(typeof jgdm == 'object'){
					params.jgdm = jgdm.jgdm;
					params.vc_fldm = jgdm.vc_fldm;
				}
				var returndata = commonUtil.commonQueryHttppost("/rest/queryDataBySql/020301/04",params);
				$("#"+domid).val(returndata[0].mc);
				return returndata[0].mc;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 校验日期是否合法
		 * @param {Object} d
		 */
		checkDate : function (d){
			if(!d){
				return false;
			}
		    var ds=d.match(/\d+/g),ts=['getFullYear','getMonth','getDate'];
		    var d=new Date(d.replace(/-/g,'/')),i=3;
		    ds[1]--;
		    while(i--){
		     	if( ds[i]*1!=d[ts[i]]()){
		     		return false;
		     	}
		    }
		    return true;
		},
		
		/**
		 * 获取操作员区县及以上代码
		 * @param {Object} user
		 */
		getUserXzqxDm : function(user){
			if(user){
				user = commonUtil.getUser();
			}
			var dm = user.xzqh;
		    if(dm.substr(dm.length -2) == '00'){
		    	dm = dm.substr(0, 6);
		    }
		    return dm;
		},
		/**
		 * 校验日期格式
		 * @param {Object} d
		 */
		checkDate : function (d){
			if(!d){
				return false;
			}
		    var ds=d.match(/\d+/g),ts=['getFullYear','getMonth','getDate'];
		    var d=new Date(d.replace(/-/g,'/')),i=3;
		    ds[1]--;
		    while(i--){
		     	if( ds[i]*1!=d[ts[i]]()){
		     		return false;
		     	}
		    }
		    return true;
		},
		/**
		 * 校验正整数
		 * @param {Object} s
		 */
		isPositiveInteger : function(s){
			var re = /^[0-9]+$/ ;
     		return re.test(s);
		},
		/**
      	 * 获取配置文件
      	 * @param {Object} key
      	 */
      	getConfig : function(key){
			try{
				var path = commonUtil.getBaseUrl();
				url = path + "/public/data/serviceUrl.json";
				var value = "";
				$.ajax({
		            type: "GET",
		            async: false,
		            dataType: "json",
		            url: url,
		            cache: false,
		            success: function (data) {
		            	/*if(key.indexOf('url') >= 0){//url参数需要区分内外网
		            		var inurl = commonUtil.uncompileStr(data.inurl);
							var outurl = commonUtil.uncompileStr(data.outurl);
							var curWwwPath = window.document.location.href;  
							var pathName = window.document.location.pathname;  
						    var pos = curWwwPath.indexOf(pathName);
						    var localhostPaht = curWwwPath.substring(0, pos);
						    if(inurl.indexOf(localhostPaht) >= 0){
						    	value = inurl + commonUtil.uncompileStr(data[key]);
						    }else{
						    	value = outurl + commonUtil.uncompileStr(data[key]);
						    }
		            	}else{*/
		            		if(data[key]){
			            		value = commonUtil.uncompileStr(data[key]);
			            	}
		            	//}
		            },
		            error: function (err) {
		                alert('获取配置信息出错【' + key + "】");
		                return;
		            }
		        });
		        return value;
			}catch(e){
		    	commonUtil.openErrorTracePanel(e);
		    }
		},
		/*
		 * 获取项目路径
		 */
		getBaseUrl : function(){
			var basepath = window.document.location.href;  
			var index_length = basepath.indexOf('jwythglxt');
			basepath = basepath.substr(0, index_length + 9);
			return basepath;
		},
		/**
		 * 日期加月份
		 * @param {Object} date
		 * @param {Object} num
		 */
		add_months : function(date, num){
        	if(!date){
        		date = commonUtil.getClientData("0");
        	}
        	var datas = date.split("-");
        	var d = new Date();
        	d.setFullYear(datas[0], datas[1]-1, 1);
			var newDay= new Date(d.getFullYear(), d.getMonth() + 1 + num, 0).getDate();//获取新得到的月有多少日
			d.setDate(Math.min(datas[2], newDay));//取最小月份赋值到新月份
			d.setMonth(d.getMonth() + num);
			var strYear = d.getFullYear();
		    var strDay = d.getDate();
		    var strMonth = d.getMonth()+1;
		    if(Number(strMonth) < 10){
		    	strMonth = "0"+strMonth;
		    }
		    if(Number(strDay) < 10){
		    	strDay = "0"+strDay;
		    }
    	    var datastr = strYear+"-"+strMonth+"-"+strDay;
		    return datastr;
	    },
	    add_days : function(date,num){
	  		if(!date){
	    		date = commonUtil.getClientData("0");
	    	}
	  		var datas = date.split("-");
        	var d = new Date();
        	d.setFullYear(datas[0], datas[1]-1, datas[2]);
			d.setDate(d.getDate()+num);
			var strYear = d.getFullYear();
		    var strDay = d.getDate();
		    var strMonth = d.getMonth()+1;
		    if(Number(strMonth) < 10){
		    	strMonth = "0"+strMonth;
		    }
		    if(Number(strDay) < 10){
		    	strDay = "0"+strDay;
		    }
    	    var datastr = strYear+"-"+strMonth+"-"+strDay;
		    return datastr;
	    },
	  /**
	   * 导出excel
	   * @param {Object} queryParams
	   * @param {Object} mkbh
	   */
	  expExcel : function(param, mkbh, param_log){
			if(param){
				//记录日志
				if(param_log && param_log.ywjllog){
					var returndata = commonUtil.commonSubmitHttppost("/rest/commitData/020201/01", param_log.ywjllog);
					if(returndata.code != "1"){
						layer.alert("记录导出日志失败:" + returndata.msg, {icon: 2});
						return;
					}
				}
				var url = "/rest/exportExcel" + mkbh;
				var base64 = new Base64();
				var basestr = base64.encode(JSON.stringify(param));
				var loading = commonUtil.layerLoading();
				var baseurl = commonUtil.getServiceUrl();
				if($("#expExcelCommonIframe").length == 0){
            		$("<iframe id='expExcelCommonIframe' name='expExcelCommonIframe' style='display: none;'></iframe>").prependTo('body');
				}
				$("#expExcelCommonIframe").attr("src", baseurl + url+"?data="+basestr);
            	$("#expExcelCommonIframe").load(function(){   //不成功
            	 	commonUtil.layerCloseLoading(loading);
            	})
				commonUtil.layerCloseLoading(loading);
			}
		},
		/**
		 * 生成UUID
		 */
		generateUUID : function() {
			var d = new Date().getTime();
			var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
				var r = (d + Math.random() * 16) % 16 | 0;
				d = Math.floor(d / 16);
				return(c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
			});
			return uuid;
		},
		/**
		 * 替换特殊字符
		 */
		replaceSpecial: function(){
			$(".layui-input").keyup(function(event){
				var pos = commonUtil.getCursorPos(this);//保存原始光标位置
				var value = $(this).val();
				var v_length = value.length;
				$(this).val(value.replace(/[>%&]/,""));
				pos = pos- (v_length - $(this).val().length);//当前光标位置
				commonUtil.setCursorPos(this, pos);//设置光标位置
			});
		},
		//获取光标位置
		getCursorPos:function(obj)
		{ 
		    var CaretPos = 0; 
		    // IE Support 
		    if (document.selection) { 
		        obj.focus (); //获取光标位置函数 
		        var Sel = document.selection.createRange (); 
		        Sel.moveStart ('character', -obj.value.length);
		        CaretPos = Sel.text.length; 
		    } 
		    // Firefox/Safari/Chrome/Opera support 
		    else if (obj.selectionStart || obj.selectionStart == '0') 
		        CaretPos = obj.selectionEnd; 
		    return (CaretPos); 
		},
		//设置光标位置
	    setCursorPos:function (obj,pos) 
		{ 
		    if(obj.setSelectionRange) { //Firefox/Safari/Chrome/Opera
		        obj.focus(); //
		        obj.setSelectionRange(pos,pos); 
		    } else if (obj.createTextRange) { // IE
		        var range = obj.createTextRange(); 
		        range.collapse(true); 
		        range.moveEnd('character', pos); 
		        range.moveStart('character', pos); 
		        range.select(); 
		    } 
		}, 
		/**
		 * 获取验证码
		 */
		getVerificationCode:function(){
			try{
				var code = "";
				var url = commonUtil.getServiceUrl() + "/rest/getVerificationCode";
				//打开遮罩
				var loadings = commonUtil.layerLoading();
				$.ajax({
				     url: url,
				     type: "POST",
				     xhrFields: {
           				withCredentials: true
       				 },
       				 crossDomain: true,
				     async: false,
				     success: function(result){
				     	commonUtil.layerCloseLoading(loadings);
				    	code = result;
				     }
				});
				return code;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 初始化，导出页面excel
		 * @param {Object} data
		 */
		initExpTableExcel:function(data){
			try{
				var id = data.id;
				var title = data.title;
				var rows = data.data;
				var tr_t = "";
				var tr_b = "";
				var fields = [];
				//遍历表头
				for(var i = 0; i < title.length; i++){
					var cols = title[i];
					tr_t = tr_t + '<tr>';
					//复杂表头
					for(var j = 0; j < cols.length; j++){
						var clo = cols[j];
						if(clo.field){
							//字段名
							fields.push(clo.field);
						}
						var align = "center";
						//对齐方式
						if(clo.align){
							align = clo.align;
						}
						var rowspan = 1;
						var colspan = 1;
						if(clo.rowspan){
							rowspan = clo.rowspan;
						}
						if(clo.colspan){
							colspan = clo.colspan;
						}
						var width = "200px";
						if(clo.width){
							width = clo.width;
						}
						var text = "";
						if(clo.title){
							text = clo.title;
						}
						tr_t = tr_t + '<th sytle="text-align:' + align +';" width="'+ width +'" colspan="'+ colspan +'" rowspan="'+ rowspan +'">' + text+ '</th>';
					}
					tr_t = tr_t + '</tr>';
				}
				$("#" + id).find('thead').empty();
				$("#" + id).find('thead').append(tr_t);
				//遍历数据
				for(var i = 0; i < rows.length; i++){
					var row = rows[i];
					tr_b = tr_b + '<tr>';
					for(var j = 0; j < fields.length; j++){
						//遍历每行字段
						var fel = fields[j];
						var vaule = "";
						if(row[fel]){
							vaule = row[fel];
						}
						tr_b = tr_b + '<td>' + vaule + '</td>';
					}
					tr_b = tr_b + '</tr>';
				}
				$("#" + id).find('tbody').empty();
				$("#" + id).find('tbody').append(tr_b);
			}catch(e){
	       		commonUtil.openErrorTracePanel(e);
	       }
		},
		/**
		 * 删除上传的图片
		 */
		commonCommitHttppost_delFileById : function(url){
			try{
				var returndata = "";
				$.ajax({
		            type: "GET",
		            async: false,
		            dataType: "json",
		            xhrFields: {
           				withCredentials: true
       				},
       				crossDomain: true,
		            url: url,
		            cache: false,
		            success: function (data) {
		              	returndata = data;
		            },
		            error: function (err) {
		                alert('获取数据服务器地址出错！');
		                return;
		            }
		        });
		        return returndata;
			}catch(e){
		    	commonUtil.openErrorTracePanel(e);
		    }
		},
		/**
		 * 深拷贝并且去除所有元素中的首尾空格
		 * @param obj
		 * @returns {*}
		 */
		deepCopyTrim : function(obj) {
			if (obj instanceof Array) {
				var n = [];
				for (var i = 0; i < obj.length; ++i) {
					n[i] = _commonutil.deepCopyTrim(obj[i]);
				}
				return n;
			} else if (obj instanceof Object) {
				var n = {}
				for (var i in obj) {
					n[i] = _commonutil.deepCopyTrim(obj[i]);
				}
				return n;
			} else if (typeof obj == 'string') {
				return obj.trim();
			} else {
				return obj;
			}
		},
		getNl:function(csrq, jsrq){
            jsrq = jsrq || commonUtil.getClientData("0");
            var s_yy=new Date(csrq).getFullYear();
            var s_mm=new Date(csrq).getMonth()+1;
            var s_dd=new Date(csrq).getDate();
            var e_yy=new Date(jsrq).getFullYear();
            var e_mm=new Date(jsrq).getMonth()+1;
            var e_dd=new Date(jsrq).getDate();
            var nl=e_yy-s_yy;
            if(s_mm>e_mm||(s_mm==e_mm&&s_dd>e_dd)){
                nl--;
            }
            return nl;
       },
       validate_wd_date : function(){
			$(".lay_date").keyup(function(event){ 
				var value = $(this).val();
				var keycode = event.keyCode;
				if(value.length == 5 && keycode != 8 && keycode != 189){
					$(this).val(value.substr(0, 4) + "-" + value.substr(4, 1));
				}
				if(value.length == 8 && keycode != 8 && keycode != 189){
					$(this).val(value.substr(0, 7) + "-" + value.substr(7, 1));
				}
				if(value.length >= 10 && keycode != 8 && keycode != 13){
					$(this).val(value.substr(0, 10));
				}
				var value_ = $(this).val();
				if(value_.length == 6){
					var m = value_.substr(5);
					if(m > 1){
						$(this).val(value_.substr(0,5) + '0' + value_.substr(5));
					}
				}
				if(value_.length == 9){
					var d = value_.substr(8);
					if(d > 3){
						$(this).val(value_.substr(0,8) + '0' + value_.substr(8));
					}
				}
			}); 
			$(".lay_date").blur(function(event){ 
				if ($(this).data('novalidate')) return; // 增加不校验错误的判断
				var strDate = $(this).val();
				var point = $(this).offset()
				var offset = [point.top-52,point.left];
				if(strDate){
					if (strDate.length != 10) {  
						layer.msg('日期格式不正确!',{
							offset: offset
						});
						$(this).val('');
						var id = $(this).attr('id');
						if(id){
							setTimeout(function(){
								$("#"+id).focus();
							},100);
						}
						return;
					}  
					var reg = /^[0-9]*$/;
					if(!reg.test(strDate.substr( 0, 4)) || !reg.test(strDate.substr( 5, 2)) || !reg.test(strDate.substr( 8, 2))){
						layer.msg('日期格式不正确!',{
							offset: offset
						});
						$(this).val('');
						var id = $(this).attr('id');
						if(id){
							setTimeout(function(){
								$("#"+id).focus();
							},100);
						}
						return;
					}
					var dtDate = null ;
					var nYear = parseInt( strDate.substr( 0, 4 ), 10 ) ;  
					var nMonth = parseInt( strDate.substr( 5,  2), 10 ) ;  
					var nDay = parseInt( strDate.substr( 8, 2 ), 10 ) ;  
					if( isNaN( nYear ) == true || isNaN( nMonth ) == true || isNaN( nDay ) == true )  {  
						layer.msg('日期格式不正确!',{
							offset: offset
						});
						$(this).val('');
						var id = $(this).attr('id');
						if(id){
							setTimeout(function(){
								$("#"+id).focus();
							},100);
						}
						return;
					}  
					dtDate = new Date( nYear, nMonth - 1, nDay ) ; 
					if( nYear != dtDate.getFullYear() || ( nMonth - 1 ) != dtDate.getMonth() || nDay != dtDate.getDate() ) {  
						layer.msg('日期格式不正确!',{
							offset: offset
						});
						$(this).val('');
						var id = $(this).attr('id');
						if(id){
							setTimeout(function(){
								$("#"+id).focus();
							},100);
						}
						return;
					}  
				}
				
			}); 
		},
		/**
		 * 字符串解密
		 * @param {Object} code
		 */
		uncompileStr: function (code){   
			code = unescape(code);      
			var c=String.fromCharCode(code.charCodeAt(0)-code.length);      
			for(var i=1;i<code.length;i++){      
			  c+=String.fromCharCode(code.charCodeAt(i)-c.charCodeAt(i-1));      
 			}      
 			return c;
		},
		/**
		 * 校验密码安全
		 * @param {Object} username
		 * @param {Object} password
		 */
		validatePassword:function(username,password){
			var validResut = {};
            var str3 = "ABCDEFGHIJKLMNOPQRST0123456789876543210TSRQPONMLKJIHGFEDCBA";
            var str4 = "QWERTYUIOPASDFGHJKLZXCVBNMNBVCXZLKJHGFDSAPOIUYTREWQ";
            username = username.toUpperCase();
            password = password.toUpperCase();
            validResut.valid = "1";
            validResut.msg = "验证通过";
            if(password.length < 6){//不能小于6位
                validResut.valid = "0";
                validResut.msg = "密码小于6位";
                return validResut;
            }
            if(password.indexOf(username) > -1 || username.indexOf(password) > -1){//用户名和密码不能互相包含
                validResut.valid = "0";
                validResut.msg = "用户名和密码相似或相同";
                return validResut;
            }
            if(!(/[0-9]+[a-zA-Z]+[0-9a-zA-Z]*|[a-zA-Z]+[0-9]+[0-9a-zA-Z]*/.test(password))){//必须数字加字母组合
                validResut.valid = "0";
                validResut.msg = "必须数字加字母组合";
                return validResut;
            }
            if(/([0-9a-zA-Z])\1{3}/.test(password)){//同一字符连续出现三次
                validResut.valid = "0";
                validResut.msg = "相同字符连续出现3次";
                return validResut;
            }
            for(var i = 0 ; i < password.length-3 ; i++){//任意连续三个位置字符，不能是连续字符
                if(str3.indexOf(password.substr(i,3))>-1){
                    validResut.valid = "0";
                    validResut.msg = "存在连续字符3个";
                    return validResut;
                }
            }
            for(var i = 0 ; i < password.length-4 ; i++){//任意连续四个位置字符，不能是连续字符
                if(str4.indexOf(password.substr(i,4))>-1){
                    validResut.valid = "0";
                    validResut.msg = "存在连续字符4个";
                    return validResut;
                }
            }
            return validResut;
		},

		/**
		 * 从对象中获取编码和名称
		 * @param obj 对象
		 * @param fieldCode 编码字段名
		 * @param fieldName 名称字段名
		 * @param seperator 连接符,不带的话默认为-
		 */
		getCodeAndName : function (obj, fieldCode, fieldName, seperator) {
			if (!obj || !fieldCode) {
				return '';
			}
			var valCode = obj[fieldCode] ? obj[fieldCode] : '';
			if (!fieldName || !obj[fieldName]) {
				return valCode;
			}
			return valCode + (seperator ? seperator : '-') + obj[fieldName];
		},
		/**
		 * 隐藏按钮控制用户操作权限
		 */
		hideRoleBt: function(){
			$("button[btdm]").hide();
		},
		/**
		 * 显示有权限的按钮
		 * @param {Object} arr
		 */
		showRoleBt: function(user){
			var yhqx = user.yhqx;
			var arr = [];
			$("button[btdm]").each(function(index,item){
				if($.inArray($(item).attr('btdm'), yhqx) >= 0){
					$(item).show();
				} else {
					$(item).remove();
				}
			});
		},
		/**
		 * 获取行政区划省级信息
		 * @param {Object} diccode
		 */
		getXzqhSheng : function(){
			try{
				var dicdata = [];
				if(parent.parent.index && parent.parent.index.getXzqhSheng){
					//首先取index页面缓存
					dicdata = parent.parent.index.getXzqhSheng();
				}else if(parent.index && parent.index.getXzqhSheng){
					//首先取index页面缓存
					dicdata = parent.index.getXzqhSheng();
				}else{
					//取数据库
					dicdata = commonDic.getXzqhSheng();
				}
				return dicdata;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 根据页面元素加载选项组行政区划
		 * lay-filter, load-child-dom 属性的值按例子输入,根据行政级别分别为 xzqh_sheng,xzqh_shi,xzqh_xian,xzqh_xiang,xzqh_cun
		 * id, name 为实际表字段
		 * 传入选项组id 
		 * 如 ccommonUtil.loadXzqhGroupById("hjdzSelect");
		 * 页面代码如下
				 <div class="layui-col-xs12 tree-selected-container">
					<div class="layui-form-item">
						<label class="layui-form-label">户籍地址：</label>
						<div class="parent-select-container" id="hjdzSelect">
							<div class="child-select-container">
								<div class="select-container">
									<select id="xzqh_sheng_id" name="xzqh_sheng_id"  lay-search="" lay-filter="xzqh_sheng" load-child-dom="xzqh_shi">
					        			<option value=""></option>
				        			</select>
								</div>
						        <span class="dd-span">省</span>
							</div>
							<div class="child-select-container">
								<div class="select-container">
									<select id="xzqh_shi_id" name="xzqh_shi_id"  lay-search="" lay-filter="xzqh_shi" load-child-dom="xzqh_xian">
							        	<option value=""></option>
						        	</select>
								</div>
						        <span class="dd-span">市</span>
							</div>
							<div class="child-select-container">
								<div class="select-container">
									<select id="xzqh_xian_id" name="xzqh_xian_id"  lay-search="" lay-filter="xzqh_xian" load-child-dom="xzqh_xiang">
							        	<option value=""></option>
						        	</select>
								</div>
						        <span class="dd-span">县</span>
							</div>
							<div class="child-select-container">
								<div class="select-container">
									<select id="xzqh_xiang_id" name="xzqh_xiang_id"  lay-search="" lay-filter="xzqh_xiang" load-child-dom="xzqh_cun">
							        	<option value=""></option>
						        	</select>
								</div>
						        <span class="dd-span">乡</span>
							</div>
							<div class="child-select-container">
								<div class="select-container">
									<select id="xzqh_cun_id" name="xzqh_cun_id"  lay-search="" lay-filter="xzqh_cun">
							        	<option value=""></option>
						        	</select>
								</div>
						        <span class="dd-span">村</span>
							</div>
						</div>
					</div>
				</div>
		 */
		loadXzqhGroupById : function(id){
			$("#"+id+" [load-child-dom]").each(function(index, item){
				var xzqhFilter = $(item).attr("lay-filter");
				var xzqhChild = $(item).attr("load-child-dom");
				//初始化省级区划
				if(xzqhChild=="xzqh_shi"){
					var data_xzqh_sheng = commonUtil.getXzqhSheng();
					var param_xzqh_sheng = {};
					param_xzqh_sheng.domid = $(item).attr("id");
					param_xzqh_sheng.data = data_xzqh_sheng;
					commonUtil.loadDic(param_xzqh_sheng);
				}
				//初始化下拉选触发事件,加载下级区划
				layui.form.on('select('+xzqhFilter+')', function(data){
					//递归清空下级区划的选项框
					var clearXjqh = function(domData){
						var clearChild = domData.attr("load-child-dom");
						if(clearChild){
							var xzqhDom = domData.parent().parent().parent().find("[lay-filter="+clearChild+"]");
							var param = {};
							param.domid = xzqhDom.attr("id");
							param.data = {};
							commonUtil.loadDic(param);
							clearXjqh(xzqhDom);
						} else {
							return;
						}
					}
					
					//获取下级区划dom
					var xjqhFilterId = $(data.elem).attr("load-child-dom");
					//给下级赋值
					if(data.value && xjqhFilterId){
						var xjqhDom = $(data.elem).parent().parent().parent().find("[lay-filter="+xjqhFilterId+"]");
						var data_xzqh = commonUtil.getXzqhBySjdm(data.value);
						var param_xzqh = {};
						//获取下级区划ID
						param_xzqh.domid = xjqhDom.attr("id");
						param_xzqh.data = data_xzqh;
						commonUtil.loadDic(param_xzqh);
						//本级别有值,清空下下级所有列表
						clearXjqh(xjqhDom);
						layui.form.render('select');
					}else{
						//本级别无值,清空下级列表所有
						clearXjqh($(data.elem));
						layui.form.render('select');
					}
				});
			});
		},
		/**
		 * 加载户籍地址数据，根据选项组id和数据 对应loadXzqhGroupById初始化的行政区划选项组
		 * @param {Object} id 选项组id
		 * @param {Object} data 数据
		 * 调用后需要render 异步加载
		 */
		loadXzqhGroupDatas : function(id,data){
			$("#"+id).find("select").each(function(index, obj){
				var domId = $(obj).attr("id");
				var filterId = $(obj).attr("lay-filter");
				var childFilterId = $(obj).attr("load-child-dom");
				var childId = $("#"+id).find("[lay-filter='"+childFilterId+"']").attr("id");
				if(data[domId] && childFilterId){
					commonUtil.getXzqhBySjdm(data[domId], function(xzqhDatas){
						var childParam = {};
						childParam.domid = childId;
						childParam.data = xzqhDatas;
						childParam.selectvalue = data[childId];
						commonUtil.loadDic(childParam);
						layui.form.render('select');
					});
				}
			});
		},
		initWgdmZtree:function(treeid,divid,callback1,jgwgdm){
			try{
				var param;
				if(jgwgdm){
					param = {"sjdm": jgwgdm};
				} else {
					param = {"jgwgdm": user.wgdm};
				}
            	var returndata = commonUtil.commonQueryHttppost('/rest/queryDataBySql/020801/1', param);
                for(var i = 0; i < returndata.length; i++){
                	returndata[i].isParent = returndata[i].isparent;
                }
                var setting = {
                    data: {
                        key: {
                            name: 'text'
                        },
                        simpleData: {
                            enable: true,
                            idKey: 'id',
                            pIdKey: 'sjid'
                        }
                    },
                    callback: {
                        onClick: function (event, treeId, node) {
							$("#"+divid).hide();
							if(callback1){
								callback1(event, treeId, node);
							}
                        },
                        onExpand : function (event, treeId, treeNode) {
                        	if(!treeNode.isload){
                        		var notes_children = treeNode.children;
                        		if(notes_children && notes_children.length > 0){
                        			return;
                        		}
                        		
                        		var cdata = commonUtil.commonQueryHttppost('/rest/queryDataBySql/020801/1', {"sjdm":treeNode.id});
                        		for(var i = 0; i < cdata.length; i++){
			                		cdata[i].isParent = cdata[i].isparent;
			                	}
                        		var treeObj = $.fn.zTree.getZTreeObj(treeid);
                            	treeObj.addNodes(treeNode, cdata);
                        	}
                            treeNode.isload = true;
                        }
                    }
                };
                treeObj = $.fn.zTree.init($("#"+treeid), setting, returndata);
                $("#"+divid).show();
                $(document).bind('click',function(e){
               		var showElem=$('#'+divid);
               		if(!showElem.is(":hidden")){
               			if(!($(e.target).hasClass('ztree_show')) && e.target.tagName != 'SPAN'){
							showElem.hide();
					    }
               		}
               });
            }catch(e){
                commonUtil.openErrorTracePanel(e);
            }
		},
		/**
		 * 初始化行政区划树
		 */
		initXzqhZtree : function(domid,divid,callback1){
			try{
            	var param = {};
            	param.xzqh = user.xzqh;
            	param.xzdm = user.xzqh.substring(0,6);
            	var returndata = commonUtil.commonQueryHttppost('/rest/queryDataBySql/010103/7', param);
                for(var i = 0; i < returndata.length; i++){
                	returndata[i].isParent = returndata[i].isparent;
                }
                var setting = {
                    data: {
                        key: {
                            name: 'text'
                        },
                        simpleData: {
                            enable: true,
                            idKey: 'id',
                            pIdKey: 'sjid'
                        }
                    },
                    callback: {
                        onClick: function (event, treeId, node) {
							if(callback1){
								callback1(event, treeId, node);
							}
							$("#"+divid).hide();
                        },
                        onExpand : function (event, treeId, treeNode) {
                        	if(!treeNode.isload){
                        		var notes_children = treeNode.children;
                        		if(notes_children && notes_children.length > 0){
                        			return;
                        		}
                        		
                        		var cdata = commonUtil.commonQueryHttppost('/rest/queryDataBySql/010103/7', {"xzdm":user.xzqh.substring(0,6),"sjid": treeNode.id});
                        		for(var i = 0; i < cdata.length; i++){
			                		cdata[i].isParent = cdata[i].isparent;
			                	}
                        		var treeObj = $.fn.zTree.getZTreeObj(domid);
                            	treeObj.addNodes(treeNode, cdata);
                        	}
                            treeNode.isload = true;
                        }
                    }
                };
                treeObj = $.fn.zTree.init($("#"+domid), setting, returndata);
                $("#"+divid).show();
                $(document).bind('click',function(e){
               		var showElem=$('#'+divid);
               		if(!showElem.is(":hidden")){
               			if(!($(e.target).hasClass('ztree_show')) && e.target.tagName != 'SPAN'){
							showElem.hide();
					    }
               		}
               });
            }catch(e){
                commonUtil.openErrorTracePanel(e);
            }
		},
		clearWgdm : function(domid,domid2){
			$("#"+domid).val('');
			$("#"+domid2).val('');
		},
		/**
		 * 初始化构建下拉选择机构树
		 * @param {Object} treeid
		 * @param {Object} divid
		 * @param {Object} type 
		 * @param {Object} callback1
		 * @param sjjgid 	上级机构id
		 * @param jgidlength 限制机构级别
		 */
		initYljgZtree:function(treeid, divid, callback1, type, sjjgid, jgidlength){
			try{
            	var param = {};
            	param.czyjgid = user.jgid;
            	if(sjjgid){
            		param.czyjgid = sjjgid;
            	}
            	//查询所有机构
            	if(type == 1){
            		//超级管理员
            		param.superadmin = "1";
            	}
            	var returndata = commonUtil.commonQueryHttppost('/rest/queryDataBySql/010103/1', param);
            	//去掉机构id的长度 大于 jgidlength 的机构,限制层级
            	if(jgidlength){
            		for (var i = returndata.length-1;i >= 0 ;i--) {
				        if (returndata[i].id && returndata[i].id.length>jgidlength) {
				            returndata.splice(i,1);  //执行后length会减一
				        }
				    }
            	}
                for(var i = 0; i < returndata.length; i++){
                	//限制机构的时候,设置末级节点
                	if(returndata[i].id && returndata[i].id.length==jgidlength){
                		returndata[i].isparent = false;
                	}
                	returndata[i].isParent = returndata[i].isparent;
                }
                var setting = {
                    data: {
                        key: {
                            name: 'text'
                        },
                        simpleData: {
                            enable: true,
                            idKey: 'id',
                            pIdKey: 'sjid'
                        }
                    },
                    callback: {
                        onClick: function (event, treeId, node) {
							$("#"+divid).hide();
							if(callback1){
								callback1(event, treeId, node);
							}
                        },
                        onExpand : function (event, treeId, treeNode) {
                        	if(!treeNode.isload){
                        		var notes_children = treeNode.children;
                        		if(notes_children && notes_children.length > 0){
                        			return;
                        		}
                        		var cdata = commonUtil.commonQueryHttppost('/rest/queryDataBySql/010103/1', {"sjid":treeNode.id});
                        		//去掉机构id的长度 大于 jgidlength 的机构,限制层级
				            	if(jgidlength){
				            		for (var i = cdata.length-1;i >= 0 ;i--) {
								        if (cdata[i].id && cdata[i].id.length>jgidlength) {
								            cdata.splice(i,1);  //执行后length会减一
								        }
								    }
				            	}
                        		for(var i = 0; i < cdata.length; i++){
                        			//限制机构的时候,设置末级节点
				                	if(cdata[i].id && cdata[i].id.length==jgidlength){
				                		cdata[i].isparent = false;
				                	}
			                		cdata[i].isParent = cdata[i].isparent;
			                	}
                        		var treeObj = $.fn.zTree.getZTreeObj(treeid);
                            	treeObj.addNodes(treeNode, cdata);
                        	}
                            treeNode.isload = true;
                        }
                    }
                };
                treeObj = $.fn.zTree.init($("#"+treeid), setting, returndata);
                $("#"+divid).show();
                $(document).bind('click',function(e){
               		var showElem=$('#'+divid);
               		if(!showElem.is(":hidden")){
               			if(!($(e.target).hasClass('ztree_show')) && e.target.tagName != 'SPAN'){
							showElem.hide();
					    }
               		}
               });
            }catch(e){
                commonUtil.openErrorTracePanel(e);
            }
		},
		/**
		 * 点击折叠或展开表单
		 */
		foldingForm : function(tableid, callback){
			var base = location.href.replace(/\/web\/[\S]+/,'/public/images/common');
			var flag = $("#foldingBtn").attr("folding");
			if(flag == "show"){//展开
				$("#foldingBtn").attr("folding", "hide");
				$(".form-hide-row").hide();
				$("#foldingImg").attr('src', base + '/arrow_x.svg');
				if($("#" + tableid).length > 0){
					full_height = 'full-' + ($("#" + tableid).next().offset().top + 10);
					window.laytable && window.laytable.reload(tableid, {height: full_height});
				}
				typeof callback === 'function' && callback();
			}else{
				$("#foldingBtn").attr("folding", "show");
				$(".form-hide-row").show();
				$("#foldingImg").attr('src', base + '/arrow_s.svg');
				if($("#" + tableid).length > 0){
					//重新调整表格长度
					full_height = 'full-' + ($("#" + tableid).next().offset().top + 10);
					window.laytable && window.laytable.reload(tableid, {height: full_height});
				}
				typeof callback === 'function' && callback();
			}
		},
		numberCheck : function(t){
			var num = t.value;
	        var re=/^\d*$/;
	        if(!re.test(num)){
	            isNaN(parseInt(num))?t.value=0:t.value=parseInt(num);
	        }
		},
		/**
		 * 初始化label鼠标悬浮提示
		 */
		initLabelPlaceholder:function(){
			$(".layui-form-label.label-placeholder").each(function(index,obj){
				$(obj).mouseover(function() {
					var nr = '<span style="color:black;font-size:15px;">' + $(obj).text().replace("*","") +'</span>'
					layer.tips(nr, $(obj), {
						tips: [1, '#d6e3f9'],
						time: 10000
					});
				});
				$(obj).mouseout(function() {
					layer.closeAll();
				});
			});
		},
		/**
		 * 重新渲染label样式, 计算表单高度, 渲染边线
		 * @param {Object} clazz
		 */
		initZsyHeight:function(clazz){
			var doms = $(clazz);
			$.each(doms, function(i,el) {
				var parent = $(el).parent().parent().parent()[0];
				$(el).css('height',(parent.offsetHeight-1) + 'px');
				$(el).css('line-height',(parent.offsetHeight-1) + 'px');
				$(el).parent().parent().find(".edit-div-border").css('height',(parent.offsetHeight-1) + 'px');
				$(el).parent().find("input").css('height',parent.offsetHeight-1);
				$(el).parent().find(".form_inline_span").css('top',(parent.offsetHeight/2-12) + 'px');
				//$(el).css('border-right',"1px solid #D3D7E0");
				//$(el).next().find("input").css('border-left',"none");
			});
		},
		/**
		 * 校验输入框长度
		 */
		verifyInput: function(ele){
			if(ele){
				commonUtil.verifyDom(ele);
			} else {
				$(".layui-input,.layui-textarea").blur(function(){
					commonUtil.verifyDom(this);
				});
			}
		},
		/**
		 * 
		 */
		verifyDom:function(ele){
			//清除边框红色样式
			$(ele).removeClass('layui-form-danger');
			var value = $(ele).val();
			var title = $(ele).attr("lay-verify-name");
			//校验字符长度
			var max_length = $(ele).attr('max-length');
			if(max_length){
				if(value){
					//将中文替换成替换成2个空格进行比较
					if(value.replace(/[\u0391-\uFFE5]/g,"  ").length > max_length){
					    var msg = "输入长度超过限制[" + max_length + "]";
					    if(title){
					    	msg = "[" + title + "]" + msg;
					    }
						layer.msg(msg, {icon: 5, shift: 6});
						//设置边框红色样式
						$(ele).focus().addClass('layui-form-danger');
						return;
					}
				}
			}
			//校验数字长度
			var precision = $(ele).attr('precision');
			if(precision){
				//校验输入值是否为数字格式
				if(isNaN(value)){
				    var msg = "请输入数字格式";
				    if(title){
				    	msg = "[" + title + "]" + msg;
				    }
					layer.msg(msg, {icon: 5, shift: 6});
					//设置边框红色样式
					$(ele).focus().addClass('layui-form-danger');
					return;
				}
				v_arr = value.split(".");
				//输入值整数位长度
				var zs_length = v_arr[0].length;
				//输入值小数位长度
				var xs_length = 0;
				if(v_arr.length == 2){
					xs_length = v_arr[1].length;
				}
				var precision_arr = precision.split(",");
				//获取数字长度
				var n_length = precision_arr[0];
				//为数字类型
				if(!isNaN(n_length)){
					//存在小数位
					if(precision_arr.length == 2){
						//设置小数长度
						var sz_xs_length = precision_arr[1];
						//小数位数为数字
						if(!isNaN(sz_xs_length)){
							//设置整数位数
							var sz_zs_length = n_length - sz_xs_length;
							if(zs_length > sz_zs_length){
							    var msg = "输入整数长度超过限制[" + sz_zs_length + "]";
							    if(title){
							    	msg = "[" + title + "]" + msg;
							    }
								layer.msg(msg, {icon: 5, shift: 6});
								//设置边框红色样式
								$(ele).focus().addClass('layui-form-danger');
								return;
							}
							if(xs_length > sz_xs_length){
							    var msg = "输入小数长度超过限制[" + sz_xs_length + "]";
							    if(title){
							    	msg = "[" + title + "]" + msg;
							    }
								layer.msg(msg, {icon: 5, shift: 6});
								//设置边框红色样式
								$(ele).focus().addClass('layui-form-danger');
								return;
							}
						}
					}else{
						if(n_length < value.length){
						    var msg = "输入长度超过限制[" + n_length + "]";
						    if(title){
						    	msg = "[" + title + "]" + msg;
						    }
							layer.msg(msg, {icon: 5, shift: 6});
							//设置边框红色样式
							$(ele).focus().addClass('layui-form-danger');
							return;
						}
					}
				}
				
			}
			//数字范围校验
			var minRange = $(ele).attr('minRange');
			if(precision&&minRange){
				if(parseFloat(value)<parseFloat(minRange)){
					var msg = "输入值小于[" + minRange + "]";
					if(title){
						msg = "[" + title + "]" + msg;
					}
					layer.msg(msg, {icon: 5, shift: 6});
					//设置边框红色样式
					$(ele).focus().addClass('layui-form-danger');
					return;
				}
			}
			var maxRange = $(ele).attr('maxRange');
			if(precision&&maxRange){
				if(parseFloat(value)>parseFloat(maxRange)){
					var msg = "输入值大于[" + maxRange + "]";
					if(title){
						msg = "[" + title + "]" + msg;
					}
					layer.msg(msg, {icon: 5, shift: 6});
					//设置边框红色样式
					$(ele).focus().addClass('layui-form-danger');
					return;
				}
			}
			var range = $(ele).attr('range');
			if(precision&&range){
				var rangeSign=$(ele).attr('rangeSign'); 
				var minVal = parseFloat(range.split(',')[0]);
				var maxVal = parseFloat(range.split(',')[1]);
				if(parseFloat(value)<minVal||parseFloat(value)>maxVal){
					if(rangeSign){
						var msg = rangeSign;
					}else{
						var msg = "输入值超出范围[" + minVal + "-"+maxVal+"]";
						if(title){
							msg = "[" + title + "]" + msg;
						}
					}
					
					layer.msg(msg, {icon: 5, shift: 6});
					//设置边框红色样式
					$(ele).focus().addClass('layui-form-danger');
					return;
				}
			}
			//最大值目标(该值必须小于目标值)
			var maxTarget = $(ele).attr('maxTarget');
			if(precision&&maxTarget){
				var dom_id = maxTarget.split(',')[0];
				var targetName = maxTarget.split(',')[1];
				var targetValue = $(dom_id).val();
				
				if(!isNaN(parseFloat(targetValue))){
					if(parseFloat(value)>parseFloat(targetValue)){
						if(title){
							msg = "[" + title + "]" +"必须小于"+"["+targetName+"]";
						}
						layer.msg(msg, {icon: 5, shift: 6});
						//设置边框红色样式
						$(ele).focus().addClass('layui-form-danger');
						return;
					}
				}
			}
		},
		/**
		 * 常用药品引入
		 */
		cyypChoose: function(callback){
			var path = window.document.location.href;  
			var index_length = path.indexOf('web');
			path = path.substr(0, index_length + 3);
			try{
				var url = path + "/gwsz/cyypgl/cyyp_choose.html?callback=" + callback;
				url = encodeURI(url);
				var index = layer.open({
				  type: 2
				  ,title:"常用药引入"
				  ,area: ['800px', '450px']
				  ,fixed: false//不固定
				  ,maxmin: true
				  ,content: [url, 'no']
				});
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 子表添加数据时,获取tr
		 * @param config:[{type:'',data:arr,width:'%',cz_btn:''}]  array说明  {code:'',name:''};
		 * 参数说明   type: 类型  ,data: 选择数据源  如果是下拉选择框 必传 ,width:宽度,cz_btn:操作按钮,span:只读数据class="readonly-span"
		 */
		getSubDataTableTr:function(config){
			if(!config){
				return;
			}
			var tr = $('<tr></tr>');
			for(var i=0;i<config.length;i++){
				if(config[i].type=='input'){
					var td = $('<td width='+config[i].width+' class="edit-table"></td>');
					var div = $('<div class="layui-table-cell" class="edit-table" align="center"></div>')
					var input = $('<input class="layui-input" max-length="'+config[i].max+'"  lay-verify="'+config[i].required+'" lay-verify-name="'+config[i].required_name+'"/>');
					input.appendTo(div);
					div.appendTo(td);
					if(config[i].edit && config[i].edit=='readonly'){
						var zzDiv = $('<div onclick="commonUtil.showTdzzMsg($(this));" style="position:absolute;width:100%;height:28px;top:0px;background-color:red;opacity:0;z-index:99999;"></div>');
						zzDiv.appendTo(td);
					}
					td.appendTo(tr);
					continue;
				}
				if(config[i].type=='number'){
					var td = $('<td width='+config[i].width+' class="edit-table"></td>');
					var div = $('<div class="layui-table-cell" class="edit-table" align="center"></div>')
					var input = $('<input class="layui-input" precision="'+config[i].precision+'" range="'+config[i].limit+'" lay-verify="'+config[i].required+'" lay-verify-name="'+config[i].required_name+'"/>');
					input.appendTo(div);
					div.appendTo(td);
					if(config[i].edit && config[i].edit=='readonly'){
						var zzDiv = $('<div onclick="commonUtil.showTdzzMsg($(this));" style="position:absolute;width:100%;height:28px;top:0px;background-color:red;opacity:0;z-index:99999;"></div>');
						zzDiv.appendTo(td);
					}
					td.appendTo(tr);
					continue;
				}
				if(config[i].type=='select'){
					var data = config[i].data;
					var td = $('<td width='+config[i].width+' class="edit-table"></td>');
					var div = $('<div class="layui-table-cell" class="edit-table" align="center"></div>')
					var select = $("<select lay-search='' lay-filter='"+config[i].filter+"' lay-verify='"+config[i].required+"' lay-verify-name='"+config[i].required_name+"'></select>");
					if(config[i].wbjs){
						$(select).attr('lay-search-wb',config[i].wbjs);
					}
					$("<option value=''>请选择</option>").appendTo(select);
					for(var j=0;j<data.length;j++){
						var option;
						option = $("<option value='"+data[j].code+"'>"+data[j].name+"</option>");
						option.appendTo(select);
					}
					select.appendTo(div);
					div.appendTo(td);
					if(config[i].edit && config[i].edit=='readonly'){
						var zzDiv = $('<div onclick="commonUtil.showTdzzMsg($(this));" style="position:absolute;width:100%;height:28px;top:0px;background-color:red;opacity:0;z-index:99999;"></div>');
						zzDiv.appendTo(td);
					}
					td.appendTo(tr);
					continue;
				}
				if(config[i].type=='select2'){//给老数据渲染用
					var data = config[i].data;
					var td = $('<td width='+config[i].width+' class="edit-table"></td>');
					var div = $('<div class="layui-table-cell" class="edit-table" align="center"></div>')
					var select = $("<select lay-search='' lay-filter='"+config[i].filter+"' lay-verify='"+config[i].required+"' lay-verify-name='"+config[i].required_name+"'></select>");
					if(config[i].wbjs){
						$(select).attr('lay-search-wb',config[i].wbjs);
					}
					$("<option value=''>请选择</option>").appendTo(select);
					for(var j=0;j<data.length;j++){
						var option;
						option = $("<option value='"+data[j].code+"'>"+data[j].name+"</option>");
						option.appendTo(select);
					}
					select.appendTo(div);
					div.appendTo(td);
					if(config[i].edit && config[i].edit=='readonly'){
						var zzDiv = $('<div onclick="commonUtil.showTdzzMsg($(this));" style="position:absolute;width:100%;height:28px;top:0px;background-color:red;opacity:0;z-index:99999;"></div>');
						zzDiv.appendTo(td);
					}
					td.appendTo(tr);
					continue;
				}
				if(config[i].type=='date'){
					var td = $('<td width='+config[i].width+' class="edit-table"></td>');
					var div =  $('<div class="layui-table-cell" class="edit-table" align="center"></div>');
					var input = $('<input class="layui-input lay_date" lay-verify="'+config[i].required+'" lay-verify-name="'+config[i].required_name+'"/>');
					input.appendTo(div);
					div.appendTo(td);
					if(config[i].edit && config[i].edit=='readonly'){
						var zzDiv = $('<div onclick="commonUtil.showTdzzMsg($(this));" style="position:absolute;width:100%;height:28px;top:0px;background-color:red;opacity:0;z-index:99999;"></div>');
						zzDiv.appendTo(td);
					}
					td.appendTo(tr);
					continue;
				}
				if(config[i].type=='cz'){
					var td = $('<td width='+config[i].width+' class="edit-table"></td>');
					var div =  $('<div class="layui-table-cell" class="edit-table" align="center"></div>');
					var btn = $(config[i].cz_btn);
					btn.appendTo(div);
					div.appendTo(td);
					td.appendTo(tr);
					continue;
				}
				if(config[i].type=='rn'){
					var td = $('<td width='+config[i].width+' class="edit-table"></td>');
					var div = $('<div class="layui-table-cell" class="edit-table" align="center"></div>')
					var span = $('<span class="rn-span"><span>');
					span.appendTo(div);
					div.appendTo(td);
					td.appendTo(tr);
					continue;
				}
				if(config[i].type=='checkbox'){
					var td = $('<td width='+config[i].width+' class="edit-table"></td>');
					var div = $('<div class="layui-table-cell" class="edit-table" align="center"></div>')
					var input = $('<input type="checkbox" lay-verify="'+config[i].required+'" lay-verify-name="'+config[i].required_name+'" lay-skin="primary" lay-filter="'+config[i].filter+'" />');
					input.appendTo(div);
					div.appendTo(td);
					td.appendTo(tr);
					continue;
				}
				/*if(config[i].type=='chosen'){//多选下拉选
					var data = config[i].data;
					var td = $('<td width='+config[i].width+' class="edit-table"></td>');
					var div = $('<div class="layui-table-cell" class="edit-table" align="center"></div>')
					var select = $('<select class="chosen-select" multiple lay-ignore="lay-ignore"></select>');
					$("<option value=''>--请选择--</option>").appendTo(select);
					for(var j=0;j<data.length;j++){
						var option;
						option = $("<option value='"+data[j].code+"'>"+data[j].name+"</option>");
						option.appendTo(select);
					}
					select.appendTo(div);
					div.appendTo(td);
					td.appendTo(tr);
					continue;
				}*/
			}
			return tr;
		},
		/**
		 * 子表数据渲染 
		 * @param {Object} config  [{type:'',name:'',data:array,width:'%',cz_btn:''}] 
		 * @param {Object} domId  要渲染的tbodyid
		 * @param {Object} datas  要渲染的数据
		 * @param {Object} callback  回调渲染
		 */
		renderSubTable:function(config,domId,datas,callback){
			if(datas.length==0){
				return;
			}
			for(var i=0;i<datas.length;i++){
				
				var tr = $('<tr></tr>');
				//解析配置
				for(var j=0;j<config.length;j++){
					if(config[j].type=='input'){
						var td = $('<td width='+config[j].width+' class="edit-table"></td>');
						var div = $('<div class="layui-table-cell" class="edit-table" align="center"></div>');
						var input = $('<input class="layui-input" max-length="'+config[j].max+'" lay-verify="'+config[j].required+'" lay-verify-name="'+config[j].required_name+'"/>');
						input.val(datas[i][config[j].name]);
						input.appendTo(div);
						div.appendTo(td);
						if(config[j].edit && config[j].edit=='readonly'){
							var zzDiv = $('<div onclick="commonUtil.showTdzzMsg($(this));" style="position:absolute;width:100%;height:28px;top:0px;background-color:red;opacity:0;z-index:99999;"></div>');
							zzDiv.appendTo(td);
						}
						td.appendTo(tr);
						if(callback){
							callback(datas[i],config[j]);
						}
						continue;
					}
					if(config[j].type=='number'){
						var td = $('<td width='+config[j].width+' class="edit-table"></td>');
						var div = $('<div class="layui-table-cell" class="edit-table" align="center"></div>');
						var input = $('<input class="layui-input"  precision="'+config[j].precision+'" range="'+config[j].limit+'" lay-verify="'+config[j].required+'" lay-verify-name="'+config[j].required_name+'"/>');
						input.val(datas[i][config[j].name]);
						input.appendTo(div);
						div.appendTo(td);
						if(config[j].edit && config[j].edit=='readonly'){
							var zzDiv = $('<div onclick="commonUtil.showTdzzMsg($(this));" style="position:absolute;width:100%;height:28px;top:0px;background-color:red;opacity:0;z-index:99999;"></div>');
							zzDiv.appendTo(td);
						}
						td.appendTo(tr);
						continue;
					}
					if(config[j].type=='select'){
						var data = config[j].data;
						var td = $('<td width='+config[j].width+' class="edit-table"></td>');
						var div = $('<div class="layui-table-cell" class="edit-table" align="center"></div>');
						var select = $("<select lay-search='' lay-filter='"+config[j].filter+"' lay-verify='"+config[j].required+"' lay-verify-name='"+config[j].required_name+"'></select>");
						if(config[j].wbjs){
							$(select).attr('lay-search-wb',config[j].wbjs);
						}
						$("<option value=''>--请选择--</option>").appendTo(select);
						for(var x=0;x<data.length;x++){
							var option;
							if(data[x].code==datas[i][config[j].name]){
								option = $("<option value='"+data[x].code+"' selected>"+data[x].name+"</option>");
							}else{
								option = $("<option value='"+data[x].code+"'>"+data[x].name+"</option>");
							}
							option.appendTo(select);
						}
						select.appendTo(div);
						div.appendTo(td);
						if(config[j].edit && config[j].edit=='readonly'){
							var zzDiv = $('<div onclick="commonUtil.showTdzzMsg($(this));" style="position:absolute;width:100%;height:28px;top:0px;background-color:red;opacity:0;z-index:99999;"></div>');
							zzDiv.appendTo(td);
						}
						td.appendTo(tr);
						continue;
					}
					if(config[j].type=='select2'){
						var data = config[j].data;
						var td = $('<td width='+config[j].width+' class="edit-table"></td>');
						var div = $('<div class="layui-table-cell" class="edit-table" align="center"></div>');
						var select = $("<select lay-search='' lay-filter='"+config[j].filter+"' lay-verify='"+config[j].required+"' lay-verify-name='"+config[j].required_name+"'></select>");
						if(config[j].wbjs){
							$(select).attr('lay-search-wb',config[j].wbjs);
						}
						$("<option value=''>--请选择--</option>").appendTo(select);
						var optionFlag = true;
						var option;
						for(var x=0;x<data.length;x++){
							if(data[x].code==datas[i][config[j].name]){
								optionFlag = false;
								option = $("<option value='"+data[x].code+"' selected>"+data[x].name+"</option>");
							}else{
								option = $("<option value='"+data[x].code+"'>"+data[x].name+"</option>");
							}
							option.appendTo(select);
						}
						//对老数据进行处理,老数据在字典里找不到
						if(optionFlag){
							option = $("<option value='"+datas[i][config[j].name]+"' selected>"+datas[i][config[j].name2]+"</option>");
							option.appendTo(select);
						}
						
						select.appendTo(div);
						div.appendTo(td);
						if(config[j].edit && config[j].edit=='readonly'){
							var zzDiv = $('<div onclick="commonUtil.showTdzzMsg($(this));" style="position:absolute;width:100%;height:28px;top:0px;background-color:red;opacity:0;z-index:99999;"></div>');
							zzDiv.appendTo(td);
						}
						td.appendTo(tr);
						continue;
					}
					if(config[j].type=='date'){
						var td = $('<td width='+config[j].width+' class="edit-table"></td>');
						var div =  $('<div class="layui-table-cell" class="edit-table" align="center"></div>');
						var input = $('<input class="layui-input lay_date" lay-verify="'+config[j].required+'" lay-verify-name="'+config[j].required_name+'"/>');
						input.val(datas[i][config[j].name]);
						input.appendTo(div);
						div.appendTo(td);
						if(config[j].edit && config[j].edit=='readonly'){
							var zzDiv = $('<div onclick="commonUtil.showTdzzMsg($(this));" style="position:absolute;width:100%;height:28px;top:0px;background-color:red;opacity:0;z-index:99999;"></div>');
							zzDiv.appendTo(td);
						}
						td.appendTo(tr);
						continue;
					}
					if(config[j].type=='cz'){
						var td = $('<td width='+config[j].width+' class="edit-table"></td>');
						var div =  $('<div class="layui-table-cell" class="edit-table" align="center"></div>');
						var btn = $(config[j].cz_btn);
						if(callback){
							var returnTd = callback(datas[i],config[j],btn);
							if(returnTd){
								btn = returnTd;
							}
						}
						btn.appendTo(div);
						div.appendTo(td);
						td.appendTo(tr);
						continue;
					}
					if(config[j].type=='rn'){
						var td = $('<td width='+config[j].width+' class="edit-table"></td>');
						var div = $('<div class="layui-table-cell" class="edit-table" align="center"></div>');
						var span = $('<span class="rn-span">'+datas[i][config[j].name]+'<span>');
						span.appendTo(div);
						div.appendTo(td);
						td.appendTo(tr);
						continue;
					}
					if(config[j].type=='checkbox'){
						var td = $('<td width='+config[j].width+' class="edit-table"></td>');
						var div = $('<div class="layui-table-cell" class="edit-table" align="center"></div>');
						var input;
						if(datas[i][config[j].name]=="1"){
							input = $('<input type="checkbox" lay-filter="'+config[j].filter+'" lay-skin="primary" checked/>');
						} else {
							input = $('<input type="checkbox" lay-filter="'+config[j].filter+'" lay-skin="primary"/>');
						}
						input.appendTo(div);
						div.appendTo(td);
						td.appendTo(tr);
						continue;
					}
					if(config[j].type == 'hidden'){//tr中加入隐藏域
						tr.attr(config[j].name + '_hidden', datas[i][config[j].name]);
					}
				}
				tr.appendTo($(domId))
				if(callback){
					callback(tr);
				}
			}
		},
		showTdzzMsg:function(zzObj){
			var zzMsg = zzObj.parent().find("input").val();
			if(zzMsg){
				var nr = '<span style="color:black;font-size:15px;">' + zzMsg +'</span>'
				layer.tips(nr, zzObj, {
					tips: [1, '#d6e3f9'],
					time: 2000
				});
			}
		},
		/**
		 * 子表获取数据
		 * @param {Object} tableName 表名
		 * @param {Object} config 初始化配置数据
		 */
		getSubTableData:function(tableName,config){
			var arr = [];
			var trs = $('#'+tableName+' tr');
			if(trs.length>0){
				for(var i=0;i<trs.length;i++){
					var obj = new Object();
					var tds = $(trs[i]).find("td");
					//解析config
					for(var j=0;j<config.length;j++){
						if(config[j].type=="input"){
							obj[config[j].name] = $(tds[j]).find('div input').val();
							continue;
						}
						if(config[j].type=="number"){
							obj[config[j].name] = $(tds[j]).find('div input').val();
							continue;
						}
						if(config[j].type=="select"){
							obj[config[j].name] = $(tds[j]).find('div select').val();
							obj[config[j].name+"_name"] = $(tds[j]).find('div select option:selected').html();
							continue;
						}
						if(config[j].type=="select2"){
							obj[config[j].name] = $(tds[j]).find('div select').val();
							obj[config[j].name+"_name"] = $(tds[j]).find('div select option:selected').html();
							continue;
						}
						if(config[j].type=="date"){
							obj[config[j].name] = $(tds[j]).find('div input').val();
							continue;
						}
						if(config[j].type=="rn"){
							obj[config[j].name] = $(tds[j]).find('div .rn-span').text();
							continue;
						}
					}
					
					arr.push(obj);
				}
			}
			return arr;
		},
		/**
		 * 数据异常警告
		 * @param {Object} ele 当前元素
		 * @param {Object} callback 回调函数
		 * @param {Object} warnLimit 警告范围, 给单独渲染的单位用
		 */
		sjycjg:function(ele,callback,callbackFlag){
			var limitStr = $(ele).attr("warn-limit");
			if(!limitStr){
				return;
			}
			var limitArr = limitStr.split(",");
			var min = limitArr[0];
			var max = limitArr[1];
			var ycStr = "";//异常提示字符
			var eleDw =  $(ele).parent().find("span").text();
			var eleLabel = $(ele).parent().parent().find("label");//获取元素对应的label
			var eleName = eleLabel.contents().filter(function(){return this.nodeType === 3;}).text();//字段名
			var ycFlag = eleLabel.find(".warn_flag_img");//获取异常标志
			var val = $(ele).val();
			if(val && (min-val)>0){
				ycStr = eleName +"小于"+ min + eleDw;
			}
			if(val && (val-max)>0){
				ycStr = eleName +"大于"+ max + eleDw;
			}
			var imgUrl = location.href.replace(/\/web\/[\S]+/,'/public/images/common')+"/yujing.png";
			if(val && ((val-max)>0 || (min-val)>0)){
				ycFlag.remove();
				eleLabel.append('<img class="warn_flag_img" style="bottom:1px; position:relative;" src="'+imgUrl+'" alt="'+ycStr+'" title="'+ycStr+'" />');
			} else {
				ycFlag.remove();
			}
			if(callback && callbackFlag){
				callback = eval(callback);
				callback(ele, ycStr, eleName, val, eleDw, min, max);
			}
			$(ele).off("change").on("change",function(){
				//如果没有传入回调函数,则取元素的warn-callback节点
				if(!callback){
					callback = $(ele).attr("warn-callback");
				}
				commonUtil.sjycjg(ele,callback,true);
				/*if(callback){
					callback = eval(callback);
					callback(ele, ycStr, eleName, val, eleDw, min, max);
				}*/
			});
		},
		/**
		 * 初始化数据的异常警告
		 * 标签属性 warn-limit="0,90" 数据范围
		 * 标签属性 warn-callback="grtjjl_edit.ycjgCallBack" 值改变回调函数
		 * @param {Object} dom 给单独的数据项增加警告
		 * @param {Object} warnLimit 警告范围
		 * @param {Object} callbackFlag 是否调用回调函数
		 */
		initSjycjg:function(callbackFlag){
			//如果传入dom,则单独渲染这个元素
			$("[warn-limit]").each(function(index,obj){
				commonUtil.sjycjg(obj,callbackFlag);
			});
			
		},
		/**
		 * 去掉数据异常警告
		 * @param {Object} domId
		 */
		removeSjycjg:function(domId){
			var dom = $("#"+domId);
			dom.parent().parent().find("label .warn_flag_img").remove();
			dom.removeAttr("warn-limit");
			dom.removeAttr("warn-callback");
			dom.off("change");
		},
		/**
		 * 清空对象内的所有数据
		 * @param {Object} domSelect 选择器
		 */
		resetDoms : function(domSelect){
			try{
				if(domSelect){
					$(domSelect).find("input,textarea").each(function(i,ele){
						var tagName = $(ele).attr("type");
						$(ele).attr("lay-verify","");
						if(tagName == 'checkbox'){
							$(ele).prop('checked',false);
						}else if(tagName == 'radio'){
							$(ele).prop('checked',false);
						} else {
							$(ele).val('');
						}
					});
					$(domSelect).find("select").val("");
					$(domSelect).find("select").attr("lay-verify","");
					$(domSelect).find("select[class='chosen-select']").val([]).trigger("chosen:updated");
					form.render();
				}
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 将对象内的输入框变为必填
		 * @param {Object} domSelect 选择器
		 */
		setDomsRequired : function(domSelect){
			try{
				if(domSelect){
					$(domSelect).find("input,textarea").each(function(i,ele){
						$(ele).attr("lay-verify","required");
					});
					$(domSelect).find("select").attr("lay-verify","required");
				}
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 禁止时间组件输入
		 */
		disableInputDate:function(ele){
			var obj;
			if(ele){
				obj= $(ele);
			} else {
				obj = $(".layui-input.lay_date");
			}
			obj.each(function(i,d){
				$(d).on("keyup",function(){
					$(this).val("");
				})
			});
		},
		/**
		 * 查找要对比高血压,糖尿病的数据
		 */
		seekContrastData : function(sfrq,daid){
			var param = {};
			param.sfrq = sfrq;
			param.daid = daid;
			param.jgid = user.jgid;
			var returnData = commonUtil.commonQueryHttppost("/rest/queryDataBySql/020606/09",param);
			var data = {};
			if(returnData.length > 0){
				return returnData;
			}
			return [];
		},
		/**
		 * 将高血压糖尿病随访数据存入缓存
		 * @param {Object} sfrq
		 * @param {Object} sfrqDataCache
		 */
		getComplieData : function(sfrq,sfrqDataCache,zxid){
			var flag = false;
			for(var i = 0;i < sfrqDataCache.length; i++){
				if(sfrqDataCache[i].sfrq == sfrq){
					flag = true;
					break;
				}
			}
			if(!flag){//若缓存中无数据，访问数据库
				var data = commonUtil.seekContrastData(sfrq,zxid);
				var param = {};
				param.sfrq = sfrq;
				param.data = data;
				sfrqDataCache.push(param);
			}
			return sfrqDataCache;
		},
		/**
		 * 比较提示
		 * @param {Object} sfrq 随访日期
		 * @param {Object} sfrqDataCache  随访日期数据缓存
		 * @param {Object} zxid 档案id
		 * @param {Object} domid 元素id
		 * @param {Object} sjlx 数据类型:xy-吸烟 xcxy-下次吸烟 yj-饮酒 xcyj-下次饮酒
		 */
		compareDataShow : function(sfrq,sfrqDataCache,zxid,domid,sjlx){
			var value = $("#"+domid).val();
			sfrqDataCache = commonUtil.getComplieData(sfrq,sfrqDataCache,zxid);
			var data = [];
			var gxyflag ;
			var tnbflag;
			for(var i = 0;i<sfrqDataCache.length;i++){
				if(sfrq == sfrqDataCache[i].sfrq){
					data = sfrqDataCache[i].data;
					break;
				}
			}
			for(var j = 0; j<data.length; j++){
				if(data[j]){
					if(data[j].lx == "gxy"){
						gxyflag = commonUtil.tipCompareData(data[j],value,sjlx);
					}
					if(data[j].lx == "tnb"){
						tnbflag = commonUtil.tipCompareData(data[j],value,sjlx);
					}
				}
			}
			var msg = "";
			var tslx = "";
			var dw ="";
			if(sjlx == "xy"){
				tslx = "吸烟";
				dw = "支/天";
			}else if(sjlx == "xcxy"){
				tslx = "下次吸烟量";
				dw ="支/天";
			}else if(sjlx == "yj"){
				tslx = "饮酒";
				dw ="两/天";
			}else if(sjlx == "xcyj"){
				tslx = "下次饮酒量";
				dw ="两/天";
			}
			if(gxyflag){
				msg += "高血压"+tslx+"为"+gxyflag+dw+",与当前值不符\n";
			}
			if(tnbflag){
				msg += "糖尿病"+tslx+"为"+tnbflag+dw+",与当前值不符\n";
			}
			if(msg){
				layer.msg(msg, {icon: 5, shift: 6});
				$("#"+domid).focus().addClass('layui-form-danger');
			}
			return;
		},
		
		tipCompareData : function(data,value,sjlx){
			if(sjlx == "xy"){//日吸烟
				if(data.rxyl && data.rxyl != value){
					return data.rxyl;
				}
			}else if(sjlx == "xcxy"){//下次吸烟
				if(data.xcrxyl && data.xcrxyl != value){
					return data.xcrxyl;
				}
			}else if(sjlx == "yj"){//饮酒
				if(data.ryjl && data.ryjl != value){
					return data.ryjl;
				}
			}else if(sjlx == "xcyj"){//下次饮酒
				if(data.xcryjl && data.xcryjl != value){
					return data.xcryjl;
				}
			}
			return "";
		},
		/**
		 * 清除隐藏域数据
		 * @param {Object} arr [{"dom":"divid","type":"input"}]
		 */
		cleanHideData : function(arr){
			
		},
		/**
		 * 打开卡选择框
		 */
		openCardChoose:function(){
			try{
				var path = window.document.location.href;  
				var index_length = path.indexOf('web');
				path = path.substr(0, index_length + 3);
				//获取宽高
				var index = layer.open({
				  type: 2
				  ,title:""
				  ,closeBtn: 0
				  ,area: ['355px', '180px']
				  ,fixed: true//不固定
				  ,maxmin: false
				  ,content: path + '/jkda/grjkda/card_choose.html'
				});
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 处理医务卡读卡结果
		 * @param {Object} data
		 */
		dellYwkResult:function(data_,callback,writeData){
			var data = data_.split(m_splitTag);
			if(data[0]=='SP_ReaderInit'){
				if(data[2]==0){//初始化成功 继续读取
					commonUtil.readCardFn(1,null,'klx');
				}else{
					var result = {code:'0',msg:'初始化读卡器失败!错误码:'+data[2]};
					commonUtil.closeDkq();
					callback(result);
				}
				
			}
			else if(data[0]=='SP_ReaderCardTpye'){
				if(data[2]==0){//读取卡类型成功,判断是否匹配当前要读取的卡类型
					if(data[1]==1){
						commonUtil.readCardFn(1,null,'jkkjcxx');
					}else{
						var result = {code:'0',msg:'卡类型不匹配!'};
						commonUtil.closeDkq();
						callback(result);
					}
					
				}else{
					var result = {code:'0',msg:'读卡类型失败!错误码:' + data[2]};
					commonUtil.closeDkq();
					callback(result);
					
				}
			}
			else if(data[0]=='HB_ReadCardInfo'){
				if(data[2]==0){//读取健康卡基本信息成功
					dk_result = {jkkh:data[1]};
					commonUtil.readCardFn(1,null,'jkkxx');
				}else{
					var result = {code:'0',msg:'读取健康卡基础信息失败!错误码:' + data[2]};
					commonUtil.closeDkq();
					callback(result);
					
				}
			}
			else if(data[0]=='HB_ReaderPatientInfos'){
				if(data[2]==0){//读取健康基本信息成功
					dk_result.jbxx = data[1];
					dk_result.code=1;
					callback(dk_result);
					dk_result = {};//重置读卡结果
					commonUtil.closeDkq();
				}else{
					var result = {code:'0',msg:'读取健康卡基础信息失败!错误码:' + data[2]};
					commonUtil.closeDkq();
					callback(result);
					
				}
			}
		},
		/**
		 * 处理社保卡读卡结果
		 * @param {Object} data_
		 * @param {Object} callback
		 */
		dellSbkResult:function(data_,callback,writeData){
			var data = data_.split(m_splitTag);
			if(data[0]=='SP_ReaderInit'){
				if(data[2]==0){//初始化成功 继续读取
					commonUtil.readCardFn(1,null,'klx');
				}else{
					var result = {code:'0',msg:'初始化读卡器失败!错误码:'+data[2]};
					commonUtil.closeDkq();
					callback(result);
				}
				
			}
			else if(data[0]=='SP_ReaderCardTpye'){
				if(data[2]==0){//读取卡类型成功,判断是否匹配当前要读取的卡类型
					if(data[1]==2){
						commonUtil.readCardFn(2,null,'sbksfzh');//读取社保卡身份证号
					}else{
						var result = {code:'0',msg:'卡类型不匹配!'};
						commonUtil.closeDkq();
						callback(result);
					}
				}else{
					var result = {code:'0',msg:'读卡类型失败!错误码:' + data[2]};
					commonUtil.closeDkq();
					callback(result);
					
				}
			}
			else if(data[0]=='SP_ReadIDInfo'){
				if(data[2]==0){//
					dk_result = {sfzh:data[1]};
					commonUtil.readCardFn(2,null,'sbkjcxx');
				}else{
					var result = {code:'0',msg:'读取社会保障卡身份证信息,错误码:'+data[2]};
					commonUtil.closeDkq();
					callback(result);
				}
			}
			else if(data[0]=='SP_ReadSicardBasicInfo'){
				if(data[2]==0){//
					dk_result.jbxx = data[1];
					dk_result.code=1;
					callback(dk_result);
					dk_result = {};//重置读卡结果
					commonUtil.closeDkq();
				}else{
					var result = {code:'0',msg:'读取社会保障卡身份证信息,错误码:'+data[2]};
					commonUtil.closeDkq();
					callback(result);
				}
			}
		},
		/**
		 * 对外暴露的读卡接口
		 * @param {Object} type 读卡类型   1 -医务卡  2-社保卡   非1或2 为写卡
		 * @param {Object} callback 回调函数
		 * @param {Object} czlx 操作类型 csh初始化  klx获取卡类型
		 * @param {Object} writeData 写卡参数
		 */
		readCard:function(type,callback,czlx,writeData){
			if(dk_result.timeout=="1"){
				layer.msg("请勿频繁点击读卡!");
			} else {
				dk_result.timeout="1";
				//初始化阻塞计时器
				setTimeout(function(){
					dk_result.timeout = "0";
				},3000);
				if(type==1){
					StartWebSocket(commonUtil.dellYwkResult,callback,{});
				}else if(type==2){
					StartWebSocket(commonUtil.dellSbkResult,callback,{});
				}else{
					StartWebSocket(commonUtil.dellWriteCard,callback,writeData);
				}
				//延迟读卡信息
				setTimeout(function(){
					commonUtil.readCardFn(type,null,'csh');
				},100);
			}
		},
		/**
		 * 读卡
		 * @param {Object} type  读卡类型   1 -医务卡  2-社保卡   非1或2 为写卡
		 * @param {Object} callback  回调函数
		 */
		readCardFn:function(type,callback,czlx,writeData){
			//初始化websocket
			//判断websocket是否初始化并且状态为1
			if(ws&&ws.readyState==1){
				//初始化读卡器
				if(czlx=='csh'){
					SP_ReaderInitAB();
				}
				//卡类型
				if(czlx=='klx'){
					SP_ReaderCardTpyeAB()
				}
				if(type==1){//医务卡读取
					//读取健康卡基础信息
					if(czlx=='jkkjcxx'){
						HB_ReadCardInfoAB();
					}
					//健康卡信息
					if(czlx=='jkkxx'){
						HB_ReaderPatientInfosAB();
					}
					if(czlx=='xrkxx'){
						HB_WritePatientInfosAB(writeData[0],writeData[1],writeData[2],writeData[3],writeData[4],
											   writeData[5],writeData[6],writeData[7],writeData[8],writeData[9],
											   writeData[10],writeData[11])
					}
				}else{
					//社保卡身份证号
					if(czlx=='sbksfzh'){
						SP_ReadIDInfoAB();
					}
					//读取社保卡基础信息
					if(czlx=='sbkjcxx'){
						SP_ReadSicardBasicInfoAB();
					}
					//社保卡信息
					if(czlx=='sbkxx'){
						HP_ReaderSbInfosAB()
					}
				}
			}
		},
		/**
		 * 处理写卡回调
		 */
		dellWriteCard:function(data_,callback,writeData){
			var data = data_.split(m_splitTag);
			if(data[0]=='SP_ReaderInit'){
				if(data[2]==0){//初始化成功 继续读取
					commonUtil.readCardFn(1,null,'klx');
				}else{
					var result = {code:'0',msg:'初始化读卡器失败!错误码:'+data[2]};
					commonUtil.closeDkq();
					callback(result);
				}
				
			}
			else if(data[0]=='SP_ReaderCardTpye'){
				if(data[2]==0){//读取卡类型成功,判断是否匹配当前要读取的卡类型
					if(data[1]==1){
						commonUtil.readCardFn(1,null,'xrkxx',writeData);
					}else{
						var result = {code:'0',msg:'卡类型不匹配!'};
						commonUtil.closeDkq();
						callback(result);
					}
					
				}else{
					var result = {code:'0',msg:'读卡类型失败!错误码:' + data[2]};
					commonUtil.closeDkq();
					callback(result);
					
				}
			}else if(data[0]=='HB_WritePatientInfos'){
				if(data[2]==0){//写卡成功
					var result = {code:'1',msg:"写入健康卡信息成功!"};
					callback(result);
				}else{
					var result = {code:'0',msg:'写入健康卡信息失败,错误码:'+data[2]};
					commonUtil.closeDkq();
					callback(result);
				}
				
			}
		},
		closeDkq:function(){
			try{
				SP_ReaderCloseAB();
			} catch(e){
				console.info(e);
			}
		},
		/**
		 * 获取用户团队权限
		 */
		getUserTdRoles : function(user){
			try{
				var userTdRoles = {};
				//取数据库,不能放js缓存,存在切换用户的情况
				userTdRoles = commonDic.getUserTdRoles(user);
//				if(parent.index && parent.index.getUserTdRoles){
//					//首先取index页面缓存
//					userTdRoles = parent.index.getUserTdRoles(user);
//				}else if(parent.parent.index && parent.parent.index.getUserTdRoles){
//					//首先取index页面缓存
//					userTdRoles = parent.parent.index.getUserTdRoles(user);
//				}else {
//					//取数据库
//					userTdRoles = commonDic.getUserTdRoles(user);
//				}
				return userTdRoles;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 关闭当前打开的子页面
		 */
		closeOpenPage:function(){
			var pageIndex = $(window.parent.document).find(".meun_tab_title li[class=layui-this]").attr("lay-id");
			parent.window.element.tabDelete('meun_tab',pageIndex);
		},
		/**
		 * 加载质控有问题字段提示
		 * @param {Object} zkmxid 质控明细id 
		 * @param {Object} url 有问题字段查询url
		 * @param {Object} img_url 提示icon url
		 */
		loadZkjgts:function(zkmxid,url,img_url,zksjj){
			var columns = commonUtil.commonQueryHttppost('/rest/queryDataBySql/020702/04',{"id":zkmxid,"zksjj":zksjj});
			for(var a=0;a<columns.length;a++){
				if(columns[a].zkbl){
					var inp_dom = $('input[name="'+columns[a].zkbl+'"');
					var sel_dom = $('select[name="'+columns[a].zkbl+'"');
					var check_dom = $('checkbox[name="'+columns[a].zkbl+'"');
					var radio_dom = $('radio[name="'+columns[a].zkbl+'"');
					if(inp_dom.length>0){
						$(inp_dom[0])
						.parent()
						.prev()
						.prepend($('<img/>').attr('style','bottom:1px; position:relative;')
						.attr('src',img_url).attr('alt',columns[a].zkgzsm).attr('title',columns[a].zkgzsm).addClass('warn_flag_img'));
					}
					if(sel_dom.length>0){
						$(sel_dom[0])
						.parent()
						.prev()
						.prepend($('<img/>').attr('style','bottom:1px; position:relative;')
						.attr('src',img_url).attr('alt',columns[a].zkgzsm).attr('title',columns[a].zkgzsm).addClass('warn_flag_img'));
					}
					if(check_dom.length>0){
						$(check_dom[0])
						.parent().parent()
						.prev()
						.prepend($('<img/>').attr('style','bottom:1px; position:relative;')
						.attr('src',img_url).attr('alt',columns[a].zkgzsm).attr('title',columns[a].zkgzsm).addClass('warn_flag_img'));
					}
					if(radio_dom.length>0){
						$(radio_dom[0])
						.parent().parent()
						.prev()
						.prepend($('<img/>').attr('style','bottom:1px; position:relative;')
						.attr('src',img_url).attr('alt',columns[a].zkgzsm).attr('title',columns[a].zkgzsm).addClass('warn_flag_img'));
					}
				}
			}
		},
		/**
		 * 特殊url替换
		 */
		replaceUrl:function(url,type){
			var urlParams = commonUtil.getUrlParams();
			var parentUrlParams = parent.commonUtil.getUrlParams();
			
			//诊间随访
			if(urlParams && urlParams.openType && urlParams.openType=="zjsf"){
				if(type=="query"){
					url = url.replace("queryDataBySql","redirectQuery");
				}
				if(type=="commit"){
					url = url.replace("commitData","redirectCommit");
				}
			}
			if(parentUrlParams && parentUrlParams.openType && parentUrlParams.openType=="zjsf"){
				if(type=="query"){
					url = url.replace("queryDataBySql","redirectQuery");
				}
				if(type=="commit"){
					url = url.replace("commitData","redirectCommit");
				}
			}
			
			//his档案调阅(查询无限制,禁止提交)
			if(urlParams && urlParams.openType && urlParams.openType=="his"){
				if(type=="query"){
					url = url.replace("queryDataBySql","his/hisQuery");
				} else {
					layer.alert("没有权限!");
				}
			}
			if(parentUrlParams && parentUrlParams.openType && parentUrlParams.openType=="his"){
				if(type=="query"){
					url = url.replace("queryDataBySql","his/hisQuery");
				} else {
					layer.alert("没有权限!");
				}
			}
			
			return url;
		},
		/**
		 * 检查是否有死亡导入信息
		 * 返回身份证号码
		 * @param {Object} id
		 * @param {Object} type 1 根据身份证号码查询 不填默认根据档案id查询
		 * @param {Object} stopReturn 默认转到死亡证明
		 */
		checkSwdrxx : function(id, type, stopReturn){
			if(!id){
				return false;
			}
			var result = [];
			if(type=="1"){
				//根据身份证号码查询死亡证明导入数据
				result = commonUtil.commonQueryHttppost("/rest/queryDataBySql/030402/02",{"sfzh":id});
			} else {
				//根据档案id查询死亡证明导入数据
				result = commonUtil.commonQueryHttppost("/rest/queryDataBySql/030402/02",{"daid":id});
			}
			//如果能查到导入死亡证明数据,则弹出页面提示框
			if(result.length>0){
				if(stopReturn){
					layer.alert("已有死亡导入信息, 无法办理业务!",{icon:2});
				} else {
					var cofIndex = layer.confirm("已有死亡导入信息，请录入死亡证明！",{btn: ['填写死亡证明','取消'],icon:3,closeBtn:0},
						function(){
							//转到死亡数据导入
							if(parent.parent.index && parent.parent.index.addTab){
								parent.parent.index.addTab('死亡证明['+result[0].xm+']', 'jkda/swgl/swzm_edit.html?daid='+result[0].id+'&type=imp&swrq='+result[0].swsj+'&jsdh='+result[0].jsdh, result[0].id+"_swzm");
								layer.close(cofIndex);
							}else{
								parent.window.location = "swzm_edit.html?daid="+id;
							}
						},
						function(){
						
						}
					);
				}
				return true;
			}
			return false;
		},
		/**
		 * 获取读卡器的websocket
		 */
		getWebsocket : function(){
			try{
				var card_ws;
				if(parent.index && parent.index.getWebsocket){
					//首先取index页面缓存
					card_ws = parent.index.getWebsocket();
				}else if(parent.parent.index && parent.parent.index.getWebsocket){
					//首先取index页面缓存
					card_ws = parent.parent.index.getWebsocket();
				}else if(parent.parent.parent.index && parent.parent.parent.index.getWebsocket){
					//首先取index页面缓存
					card_ws = parent.parent.parent.index.getWebsocket();
				}else{
					//new websocket
					card_ws = commonDic.getWebsocket();
				}
				return card_ws;
			}catch(e){
				commonUtil.openErrorTracePanel(e);
			}
		},
		/**
		 * 缓存浏览痕迹
		 */
		cacheLlhj:function(key,arr){
			var flag = false;
			for(var i=0;i<arr.length;i++){
				if(arr[i]==key){
					flag=true;
					break;
				}
			}
			if(!flag){
				arr.push(key);
			}
			return arr;
		},
		/**
		 * 格式化时间戳
		 */
		formatedDate: function(date, fmt) {
			var d = new Date(date);
			var o = {
        "M+" : d.getMonth()+1,                 //月份
        "d+" : d.getDate(),                    //日
        "h+" : d.getHours(),                   //小时
        "m+" : d.getMinutes(),                 //分
        "s+" : d.getSeconds(),                 //秒
        "q+" : Math.floor((d.getMonth()+3)/3), //季度
        "S"  : d.getMilliseconds()             //毫秒
			};
			if(/(y+)/.test(fmt))
					fmt=fmt.replace(RegExp.$1, (d.getFullYear()+"").substr(4 - RegExp.$1.length));
			for(var k in o)
					if(new RegExp("("+ k +")").test(fmt))
							fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
			return fmt;
		},
		/**
		 * 获取模板
		 */
		getTpl: function(tplName) {
			var deferred = $.Deferred();
			$.ajax({
        type: 'get',
				url: commonUtil.getBaseUrl() + "/tpl/" + tplName,
				success: function(res) {
					deferred.resolve(res);
				}
			});
			return deferred.promise(); 
		}
	}
	window.commonUtil = _commonutil;
})(window);

$(function(){
	commonUtil.replaceSpecial();
	commonUtil.validate_wd_date();
	commonUtil.verifyInput();
});	